MFC中ComboBox的属性 [英] Property of ComboBox in MFC

查看:108
本文介绍了MFC中ComboBox的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IsReadOnly 属性究竟在 ComboBox 上做了什么?

我会期望它不应该允许你改变价值或从下拉列表中选择一个项目,但你可以。



有没有办法让它真正只读?

解决方案

引用 IsReadOnly [ ^ ]:

获取或设置一个启用仅选模式的值,其中组合的内容框是可选择的但不可编辑。

该属性确定是否可以使用组合框的编辑框。

文档 [ ^ ]包含一个表格,指定当属性为真或假时你能做什么和不能做什么。



如果你想让make组合框控件完全只读设置 IsEnabled [ ^ ]属性为false。


CComboBox :: ShowDropDown隐藏DropDown是一个好主意,因此用户无法选择任何项目


如果你想让组合框的编辑控件只读,那么改变组合框的类型到删除列表。如果您选择类型作为下拉,则编辑控件仍可编辑。您应该只将此作为设计时间。在运行时,这些属性不会改变。



要在运行时更改这些属性:

首先获取组合框信息 GetComboBoxInfo()。

获取其编辑控件的句柄(COMBOBOXINFO结构的hwndItem成员)。

将编辑控件属性设置为只读SetReadOnly()。

What exactly does the IsReadOnly attribute do on the ComboBox?
I would expect it should not allow you to change the value or select an item from the drop down list, yet you can.

Is there a way to make it truly read only?

解决方案

Quote IsReadOnly[^]:

Gets or sets a value that enables selection-only mode, in which the contents of the combo box are selectable but not editable.

The property determine whether the edit box of the combo box can be used.
The documentation[^] contains a table which specifies what you can and cannot to when the property is true or false.

If you want the make the combo box control completely read only set the IsEnabled[^] property to false.


CComboBox::ShowDropDown is a good idea to hide the DropDown, so the User can't select any Item


If you want to make combo-box's edit control read only, then change combo-box's "Type" to "Drop List". If you have selected "Type" as "Drop Down", then edit control remains editable. You should do all this as "Design Time" only. At run time these properties do not change.

To change these properties at run-time:
First get Combo-box information by "GetComboBoxInfo()".
Obtain handle of its edit control(hwndItem member of COMBOBOXINFO structure).
Set edit control property to read only by "SetReadOnly()".


这篇关于MFC中ComboBox的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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