简体   繁体   English

在C#NET 3.5中使用组合框属性

[英]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)? 另一个问题,如何确定所选择的文本。例如它有4个值的索引(10,20,30和40)。如果用户选择20,我怎样才能得到他所选择的文本的文本(不是索引号,但文字)?

Thanks. 谢谢。

For a list only combobox: 仅限列表组合框:

comboBox.DropDownStyle = ComboBoxStyle.DropDownList;

to get the text: 得到文字:

string text = comboBox.Text;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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