Insert data as first item
I have a combobox which binds data from the database. It gets the data correctly but I want the first item I tried but I could not so how can I d开发者_如何学编程o that? and where in code page?
Do you want the first item from the combobox?
Object firstItem = comboBox.Items[0];
You could try something like this,
object selectedItem = comboBox1.SelectedItem;
System.Windows.Forms.MessageBox.Show(selectedItem.ToString());
This will work.You should first create the selected item
object then use it.
See here : [ComboBox.SelectedItem Property].
Feel free to tell me if I am wrong.
精彩评论