tags:

views:

221

answers:

2

hi i have a combobox in c# winform. i have to save two things against each elemet. a Text which will be displayed to user and a id against that text.

in Asp.Net we can save these values in Text and Value fields of listbox..

but how to handle this situation in winform app

A: 

comboBox1.SelectedValue; comboBox1.SelectedText;

These two will work for you.

Happy coding.

Ravia
but this will be used to get the value and text. my question is how to save these (text, value)
Mohsan
+1  A: 

You can use a BindingSource to store data. And then bind it to your ComboBox. Remember to set ComboBox.ValueMember (points to ID field) and ComboBox.DisplayMember (points to Text field) properties.

Tadas
thanks. problem Solved :)
Mohsan