I have two indexes on my combobox.
I want to take only the first index ?
Can I get some example ?
The code:
foreach (DataRow dr2 in dt2.Rows)
{
comboBox1.Items.Add(dr2["Station"].ToString() + " - " + dr2["Ime"].ToString());
}
I want to take dr2["Station"].ToString()
?
The Win Forms ComboBox
has both a SelectedIndex
and SelectedText
property.
Once your list is loaded with items you can pick which one is selected like this:
// selected by position in the list
comboBox1.SelectedIndex = 0;
// ... by value
comboBox1.SelectedText = "some value";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.