MFC ComboBox怎么设置默认项(注意是C++不是C#)
这是在类的OnInitDlg()中this->m_Combo.AddString("A");this->m_Combo.AddString("B");this->m_Co...
这是在类的OnInitDlg()中
this->m_Combo.AddString("A");
this->m_Combo.AddString("B");
this->m_Combo.AddString("O");
this->m_Combo.AddString("AB");
this->m_Combo.AddString("其他");
那么问题来了 现在程序运行时能进行血型选择
但是默认项是空白
我如何让默认项选在O型血上? 展开
this->m_Combo.AddString("A");
this->m_Combo.AddString("B");
this->m_Combo.AddString("O");
this->m_Combo.AddString("AB");
this->m_Combo.AddString("其他");
那么问题来了 现在程序运行时能进行血型选择
但是默认项是空白
我如何让默认项选在O型血上? 展开
2个回答
展开全部
给你四种方法推荐第四种、第二种 ,一、三实际是只要前缀符合就匹配的
void CMfcdlg2015Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_Combo.SelectString(-1, _T("A"));
}
void CMfcdlg2015Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_Combo.SetCurSel(m_Combo.FindStringExact(-1, _T("O")));
}
void CMfcdlg2015Dlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_Combo.SetCurSel(m_Combo.FindString(-1, _T("O")));
}
void CMfcdlg2015Dlg::OnButton4()
{
// TODO: Add your control notification handler code here
CString iTemStr;
int i;
int n = m_Combo.GetCount();
for(i=0;i<n;i++)
{
m_Combo.GetLBText(i, iTemStr);
if(iTemStr==CString(_T("O")))
{
m_Combo.SetCurSel(i);
break;
}
}
}
void CMfcdlg2015Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_Combo.SelectString(-1, _T("A"));
}
void CMfcdlg2015Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_Combo.SetCurSel(m_Combo.FindStringExact(-1, _T("O")));
}
void CMfcdlg2015Dlg::OnButton3()
{
// TODO: Add your control notification handler code here
m_Combo.SetCurSel(m_Combo.FindString(-1, _T("O")));
}
void CMfcdlg2015Dlg::OnButton4()
{
// TODO: Add your control notification handler code here
CString iTemStr;
int i;
int n = m_Combo.GetCount();
for(i=0;i<n;i++)
{
m_Combo.GetLBText(i, iTemStr);
if(iTemStr==CString(_T("O")))
{
m_Combo.SetCurSel(i);
break;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询