Object Data Binding

  • Thread starter Thread starter Davie
  • Start date Start date
D

Davie

Lets say i have an array of order objects and I wish for these objects to be
bound to a ComboBox.

public order(string id, string name, int price, string details)

order[] orders = new ...........


I know that i can bind them to a combobox by doing the following:
comboBox1.DataSource=orders;
comboBox1.DisplayMember="name";
comboBox1.ValueMember="id";


How can I set the display member to be the name element of the object and
the ValueMember be the actual object?

Many thanks.
 
Davie,

It is good idea to provide your solution for the archive in case that
someone in future has the same problem.

Thanks
Stoitcho Goutsev (100) [C# MVP]

Davie said:
Solved this problem thanks.


Davie said:
Lets say i have an array of order objects and I wish for these objects to
be bound to a ComboBox.

public order(string id, string name, int price, string details)

order[] orders = new ...........


I know that i can bind them to a combobox by doing the following:
comboBox1.DataSource=orders;
comboBox1.DisplayMember="name";
comboBox1.ValueMember="id";


How can I set the display member to be the name element of the object and
the ValueMember be the actual object?

Many thanks.
 
Back
Top