0

I have an array of base class Product that contains objects of derived classes Medication and Parapharmaceutical.

In a DataGridView control, I am trying to display all the fields (fields of the base class that are in common and also the specific fields of each derived class).

dataGridView1.DataSource = ArrayOfProducts;

dataGridView1.ColumnCount = 6;

dataGridView1.Columns[0].Name = "Reference";

...

Now the question is how to bind the properties of the array objects to the columns (the objects are of a different type) ?

imanebz
  • 79
  • 1
  • 11

1 Answers1

0

It's not exactly clear what you want to accomplish here, but it sounds like what you're needing is to set up your "ArrayOfProducts" as a DataTable in order to control the association of your data with the correct columns and datatypes. Does that help?

Justin Grant
  • 245
  • 3
  • 10
  • Yep, how can I accomplish that please ? – imanebz Apr 20 '20 at 21:51
  • Do you know the contents of your array? The answer to this thread has an simple example: https://stackoverflow.com/questions/1042618/how-to-create-a-datatable-in-c-sharp-and-how-to-add-rows – Justin Grant Apr 20 '20 at 21:57