开发者

How to prevent a combo box from selecting a value

开发者 https://www.devze.com 2022-12-11 22:12 出处:网络
I\'m using a ComboBox with the DropDownStyle = \"DropDownList\". Programatically I set the DataSource for the items in the list. Something like this :

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号