当我单击下拉菜单时,MFC 组合框控件未显示项目的完整列表

MFC Combo-Box Control is not showing the full list of items when I click the drop-down menu(当我单击下拉菜单时,MFC 组合框控件未显示项目的完整列表)

本文介绍了当我单击下拉菜单时,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 变量.

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.

我还列出了组合框控件的属性 - 只有为真的属性(其余设置为假):

I'm listing the properties of the combo-box control as well - only the properties that are true(rest are set to false):

  1. 类型 - 下拉列表
  2. 垂直滚动条
  3. 可见的制表符

这已经困扰了我好几个星期了.任何人都可以启发我吗?

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 组合框控件未显示项目的完整列表

基础教程推荐