简体   繁体   中英

Using combobox properties in C# NET 3.5

I'd like to know how to set a combobox to be read only,meaning the user cannot write text into it,but just select?

Another question,how to determinate the text of the selected choice.For example it has index of 4 values(10,20,30 and 40).If the user chooce 20,how can I get the Text of the choice he selected(Not the index number,but text)?

Thanks.

For a list only combobox:

comboBox.DropDownStyle = ComboBoxStyle.DropDownList;

to get the text:

string text = comboBox.Text;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM