Search code examples
c#winformscomboboxselectedvalue

Assign display value from a combo box to another text


I am having code to display combo box such as

da.Fill(ds1, "HDTYPE");
comboHD.DisplayMember = "hw_define";
comboHD.ValueMember = "hwd_Id";
comboHD.DataSource = ds1.Tables["HDTYPE"];

The problem is I want to assign the selected text ie, hw_define to another text field for printing the data and hwd_Id to database for saving the data. I'm able to get the selected ID(hwd_id) by using hwtype.SelectedValue. But how can I get selected - hw_define text to assign another text box?


Solution

  • You can use comboHD.Text to get he value displayed in the combo box.