CComboBox::SetCurSel

选择在组合框的列表框中的字符串。

int SetCurSel(
   int nSelect 
);

参数

  • nSelect
    指定字符串的从零开始的索引选项。 如果),在列表框中的任何当前选择移除1,并清除编辑控件。

返回值

选定项的从零开始的索引,如果消息已成功。 返回值是 CB_ERR,如果 nSelect 比项的数量大于列表中的,或者 nSelect 设置为1,清除选择。

备注

如果需要,(如果列表框中可见),列表框将字符串传递到视图。 更改在组合框上编辑控件的文本反映新的选择。 移除列表框中的所有先前选择。

示例

// Select the last item in the combo box.
int nLast = pmyComboBox->GetCount() - 1;
if (nLast >= 0)
   m_pComboBox->SetCurSel(nLast);

要求

Header: afxwin.h

请参见

参考

CComboBox选件类

层次结构图

CComboBox::GetCurSel

CB_SETCURSEL