How to prevent a combo box from selecting a value
I'm using a ComboBox with the DropDownStyle = "DropDownList". Programatically I set the DataSource for the items in the list. Something like this :
combo.DisplayMember = "Text";
combo.ValueMember = "id";
combo.DataSource = ds.tbl;
开发者_如何学Python
The list is populated correctly and the first element is selected. How do I prevent the first element from being selected?
combo.SelectedIndex = -1;
Set SelectedIndex
to -1. See here: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindex.aspx
精彩评论