我有一個小comboBox,我想用6個條目填充它...。 我寫了這個代碼:C++ MFC CComboBox是空的
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");
正如你可以看到我試過AddString()
,並InsertString()
。兩者都沒有效果。我也試過AddString()
這應該是初始化它的正確方法。
但是,我的combobox是空的。我已經調試過了,這條命令被打了但沒有任何效果。
你有什麼想法嗎?
嗨,也許你不小心簽在CComboBox的屬性的OwnerDraw設定? – Clemens
你究竟把這個代碼放在哪裏?在'OnInitDialog'中,對嗎?或沒有? – Ajay