ComboBox用户输入限制 [英] ComboBox user input restriction

查看:85
本文介绍了ComboBox用户输入限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户只能选择一项而不输入任何输入的意义上,我如何使组合框控件几乎像只读的那样.换句话说,ComboBox接受的唯一inut可能是用户选择的项目,仅此而已.我在控件中找不到与该属性相关的属性.我是否可以使用一些代码来防止用户键入自己的数据并强迫他们选择项目?

请注意,我想将下拉样式保留为下拉列表,但只需将控件的通常可编辑部分设置为只读即可.文本部分仍然必须可见,但只能同时读取.可以通过代码完成吗?如果可以,怎么办?

我知道不同的DropDownStyles,我需要应用DropDown样式,并且需要将文本的可编辑部分覆盖为只读.有人可以帮忙吗?

How do I make a combobox control almost like read only in the sense that the user may only select one of the items but not type in any input. In other words, the only inut accepted by the ComboBox may be an item selected by the user, nothing else. I cant find a property related to that in the control. Is the some code for this purpose that I can use to prevent user typing their own data and force them to select an item?

Please note that i would like to keep the dropdown style as dropdown list but just make the normally editable portion of the control a read only. The text portion must still be visible but read only at the same time. can that be done through code? if so, how?

I am aware of the different DropDownStyles, I need DropDown style to be applied and the editable portion of the text to be overridden as read only. Can anyone please help?

推荐答案

DropDownStyle属性用于获取和设置ComboBox的样式.它是ComboBoxStyle枚举的一种.
ComboBoxStyle枚举具有以下三个值.

简单-列表始终可见,文本部分可编辑.
单击下拉箭头将显示下拉列表",并且该文本部分是可编辑的.
DropDownList-通过单击向下箭头显示列表,并且该文本部分不可编辑.

请检查以确保这是最后分配的属性.
DropDownStyle property is used to gets and sets the style of a ComboBox. It is a type of ComboBoxStyle enumeration.
The ComboBoxStyle enumeration has following three values.

Simple - List is always visible and the text portion is editable.
DropDown List is displayed by clicking the down arrow and that the text portion is editable.
DropDownList - List is displayed by clicking the down arrow and that the text portion is not editable.

Please check to ensure, it is last property assigned.


我再次删除了您对该问题的转发. Ravi解释了ComboBox中的选项,可以通过阅读文档这里 [ ^ ].如果您有更多要添加的信息,请编辑上面的问题;不要只是为了从别人那里得到相同的答案而在其他地方转发.
I have again deleted your repost of this question. Ravi has explained what the options are in a ComboBox, which can be confirmed by reading the documentation here[^]. If you have further information to add then please edit the above question; don''t repost elsewhere just to get the same answer from someone else.


这篇关于ComboBox用户输入限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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