简体   繁体   English

C++ MFC CComboBox 为空

[英]C++ MFC CComboBox is empty

i've a little comboBox, and i want to fill it with 6 entries... .我有一个小组合框,我想用 6 个条目填充它...... i wrote this code:我写了这段代码:

CComboBox* dropdownList = ((CComboBox*)GetDlgItem(IDC_PROGRAMDROPDOWN));
dropdownList->Clear();
dropdownList->AddString(L"test");
dropdownList->AddString(L"test2");
dropdownList->InsertString(2,L"test3");
dropdownList->InsertString(3,L"test4");
dropdownList->InsertString(4,L"test5");

As you can see I tried AddString() , and InsertString() .如您所见,我尝试了AddString()InsertString() both with no effect.两者都没有效果。 I also tried it just with AddString() which should be the correct way at initializing it.我也只用AddString()尝试过它,这应该是初始化它的正确方法。

But, my combobox is empty.但是,我的组合框是空的。 I already debugged it, and this lines are hit but with no effect.我已经调试过了,这条线被击中但没有效果。

Do you have any idea?你有什么主意吗?

In the dialog editor, make sure you resize the ComboBox item so that its height is big enough to contain all of the items when the ComboBox is expanded.在对话框编辑器中,确保调整 ComboBox 项目的大小,使其高度足以在 ComboBox 展开时包含所有项目。 By default, it'll only be the height of the "edit control" bit of the ComboBox, which limits the expanded height.默认情况下,它只会是 ComboBox 的“编辑控件”位的高度,它限制了展开的高度。

So, in the dialog editor, click on the dropdown button bit of the Combo Box and you should see the drag handles change a bit.因此,在对话框编辑器中,单击组合框的下拉按钮位,您应该会看到拖动手柄发生了一些变化。 Drag out the new size to account for all the items in the dropdown list.拖出新大小以考虑下拉列表中的所有项目。

thanks for all your answers.感谢您的所有回答。 But it was an ugly Failure by my IDE -.-.但这是我的 IDE 的一个丑陋的失败 -.-。 I just recreated the UI-Element and it worked...我刚刚重新创建了 UI-Element 并且它起作用了......

I recreated it with the same properties (Copy & Paste)我用相同的属性重新创建了它(复制和粘贴)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM