ComboBox Values!

  • Thread starter Thread starter Lora Connors
  • Start date Start date
L

Lora Connors

I would like my ComboBox to display the 'CustomerName'
value but it should store the 'CustomerID' value whenever
it is assigned to the DataTable.LoadDataRow. Also, I need
to trap the 'CustomerID'value in the
ComboBox_SelectedIndexChanged Event whenever that event is
fired.
Thanks!
 
Hi Lora,

Assign 'CustomerName' to DisplayMember and 'CustomerID' to ValueMember.
You can retrieve the id by using SelectedValue property.
 
Hi Lora,

comboBox1.DataSource = dataTable1; // table holding customer

comboBox1.DisplayMember = "CustomerName";

comboBox1.ValueMember = "CustomerId";

Does this help?
 
Back
Top