默认项目显示在不可编辑的组合框中
Default item showing in non-editable comboBox
我的GUI C++应用程序(Visual Studio 2012)中有一个不可编辑的组合框,我想从集合中选择该框中的默认项/值(所有项/值)。希望有人能帮助我实现这一点?
假设您已经填充了禁用的组合框,如下所示:
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"
}
如代码片段所示,您只需设置当前所选项目(基于索引)
相关文章:
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 可组合的lambda/std::函数与std::可选
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 混合组合和继承的C++问题
- 我需要将多个函数组合为一个函数
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 通过组合不同的类型来创建唯一的id
- 用常见虚拟函数实现的任意组合来实现派生类的正确方法是什么
- 模板元编程:如何将参数包组合成新的参数包
- 编辑文件中的文本
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- Win32组合框,打印所选要编辑文本框的名称
- 使用列中的组合框编辑QTableView
- 如何在 QModelView 中组合模式对话框编辑器和就地小组件编辑器
- (Qt)可编辑的Q组合框:don't在输入文本时关闭弹出窗口
- 将Qline编辑与qt c++中的组合框链接
- 默认项目显示在不可编辑的组合框中
- 列编辑为QTableWidget中的组合框
- 样式:在可编辑的组合框上选择颜色