如何使组合框为只读和自动完成? [英] How to make a combobox readonly and autocomplete?

查看:68
本文介绍了如何使组合框为只读和自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用datagridviewcomboboxcolumns中的组合框轻松地做到这一点,但是它与普通组合框不一样,我不能使其变为只读(不允许用户输入任何字符),我希望用户键入时自动完成其值.
我希望它具有一些属性,例如"ReadOnly"和"AutoComplete"(都接收True/False).
您能给我建议一些解决方案吗?
非常感谢!

解决方案

因此,您想阻止用户输入任何内容,并希望当用户输入一些文本时组合框能够自动完成吗?如果所有这些都在同一个组合框上,那是不可能的...

若要使组合框为只读,请将DropDownStyle更改为DropDownList.

有一个AutoCompleteMode属性,您可以将其视为...自动完成功能. 无论如何,如果您要分别查找它们,请参考以下示例:
自动完成打开

comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
comboBox1.Focus();


自动完成关闭

comboBox1.AutoCompleteMode = AutoCompleteMode.None;
comboBox1.AutoCompleteSource = AutoCompleteSource.None;
comboBox1.Focus();


或者您可以尝试
C#自动完成组合框

comboBox只读

comboBox1.DropDownStyle = ComboBoxStyle.DropDownList



希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.


I can do that easily with comboboxes in datagridviewcomboboxcolumns, but it is not the same to normal comboboxes, I can''t make it read-only (don''t allow user to input any characters) and I want it to complete its value automatically when user types.
I hoped it had some properties like "ReadOnly" and "AutoComplete" (both receive True/False).
Could you please suggest me some solution?
Thank you so much!

解决方案

So, you want to stop the user from inputting anything and want the combobox to autocomplete when the user inputs some text? If that''s all on the same combobox then it''s impossible...

To make the combobox readonly change the DropDownStyle to DropDownList.

There is an AutoCompleteMode property, you can look at that one for...autocomplete.


Do you need both together??how??
Anyway,if you are looking for those separately,following are the examples:
Auto Complete ON

comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
comboBox1.Focus();


Auto Complete OFF

comboBox1.AutoCompleteMode = AutoCompleteMode.None;
comboBox1.AutoCompleteSource = AutoCompleteSource.None;
comboBox1.Focus();


Or You can try
C# auto complete combo box

comboBox readonly

comboBox1.DropDownStyle = ComboBoxStyle.DropDownList



I hope the above information will be helpful. If you have more concerns, please let me know.


这篇关于如何使组合框为只读和自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆