tags:

views:

69

answers:

2

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;

The list is populated correctly and the first element is selected. How do I prevent the first element from being selected?

+4  A: 
combo.SelectedIndex = -1;
Phaedrus
Ho, right. I knew that. I just didn't though about it because of another problem I have with another combobox on the same form. I'll create a separate question to explain this other problem. Thanks.
Mathieu Pagé
+2  A: 

Set SelectedIndex to -1. See here: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindex.aspx

Konamiman