0

我的 GUI C++ 应用程序(Visual Studio 2012)中有一个不可编辑的组合框,并且想从我的集合中选择该框中的默认项/值(所有项/值)。希望有人可以帮助我使这成为可能吗?

4

1 回答 1

1

假设您已经像这样填充了禁用的组合框:

LPCTSTR s[] = {_T("Blue"), _T("Red"), _T("Yellow")};

CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO_COLOR);

if(pCombo)
{
    for(int i=0; i<3; ++i)
    {
        pCombo->AddString(s[i]);
    }
    pCombo->SetCurSel(1); // <- sets the default value. here it would be "Red"
}

如代码片段所示,您只需设置当前选定的项目(基于索引)即可

于 2013-07-11T11:27:20.333 回答