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

查看:1624
本文介绍了当我单击下拉菜单时,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.

现在,当我构建应用程序, -arrow,下拉框显示第一个选项ONLY(因为我选择了通过我的代码)。但是,如果我按下键盘上的向下箭头键,它循环通过选项的顺序,我插入,但从来没有显示超过1选项在框中。所以,如果用户想要选择option3,他必须循环通过选项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):


  1. 类型 - 下拉菜单

  2. 垂直滚动条

  3. 可见的tabstop

我几个星期。

推荐答案

在对话框布局设计器中,在设计对话框时,单击向下箭头组合框。然后,您可以向下拖动组合框大纲的底部以增加其高度。

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组合框控件不显示项目的完整列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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