方法一:
CString strText;
int nIndex = m_cmbBox.GetCurSel(); //先用GetCurSel()得到选中的Item编号;
if ( nIndex != -1 ) //没有选中任何条目
{
m_cmbBox.GetLBText(nIndex, strText); // 然后用GetLBText(nIndex,m_SelText)得到文字
}
m_cmbBox.GetLBText(nIndex, strText); // 然后用GetLBText(nIndex,m_SelText)得到文字
}
m_CmbBoxWidth.SetCurSel(0); //将选中条目设置为第一个条目
方法二:
//方法一设置了comboBox 控件的Control 类型的相关变量,其实我经常用的是CString类型的相关变量,这样直接就可以获得文字。但设置Control 类型的相关变量有更大用处,可以调用AddString SetCurSel GetCurSel() 等等函数。一个comboBox 控件可以同时绑定两种类型的变量 Control 类型和CString类型