MFC Combo-Box Control is not showing the full list of items when I click the drop-down menu(当我单击下拉菜单时,MFC 组合框控件未显示完整的项目列表)
问题描述
我在 MSVS 2008 中编写了一个应用程序,它有一个 ComboBox 控件,我通过如下代码对其进行初始化:
I'm coding an app in MSVS 2008, which has a ComboBox control which I initialize thru the code as below:
static char* OptionString[4] = {"Opt1",
"Opt2",
"Opt3",
"Opt4"};
BOOL CMyAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_Option.AddString(OptionString[0]);
m_Option.AddString(OptionString[1]);
m_Option.AddString(OptionString[2]);
m_Option.AddString(OptionString[3]);
m_Option.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
在上面的代码中,m_Option
是ComboBox Control的Control变量.
In the above code, m_Option
is the Control variable for the ComboBox Control.
现在,当我构建应用程序并单击向下箭头时,下拉框仅显示第一个选项(因为我已通过代码选择了该选项).但是,如果我按下键盘上的向下箭头键,它会按照我插入的顺序循环遍历选项,但它永远不会在框中显示超过 1 个选项.因此,如果用户想要选择选项 3,他必须循环选择选项 1 和 2 !虽然一旦我使用键盘选择了任何选项,相应的事件处理程序就会被触发,但我对这种行为感到很恼火,这是可以理解的.
Now, when I build the app and click the down-arrow, the drop-down box shows the first option ONLY(since I've selected that thru my code). But, if i press down-arrow key on keyboard, it cycles thru the options in the order I've inserted, but never does it show more than 1 option in the box. So, In case an user wants to select option3, he has to cycle through options 1 and 2 !! Though once I select any option using the keyboard, the appropriate event handlers are fired, I'm miffed by this behaviour , as is understandable.
我也列出了组合框控件的属性 - 只有为 true 的属性(其余设置为 false):
I'm listing the properties of the combo-box control as well - only the properties that are true(rest are set to false):
- 类型 - 下拉列表
- 垂直滚动条
- 可见的制表符
这已经困扰了我好几个星期了.谁能赐教?
This has bugged me for weeks now. Can anyone pls enlighten me ?
推荐答案
在对话框布局设计器中,在设计对话框时,单击组合框上的向下箭头".然后,您可以向下拖动组合框轮廓的底部以增加其高度.
In the dialog layout designer, while designing the dialog, click the "down arrow" on the combobox. You can then drag down on the bottom of the combobox's outline to increase its height.
这篇关于当我单击下拉菜单时,MFC 组合框控件未显示完整的项目列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当我单击下拉菜单时,MFC 组合框控件未显示完整的项目列表
基础教程推荐
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01