效果:
当组合框下拉的时候加载数据:
void BTSInfo::OnDropdownCOMBOBTSName()
{
// TODO: Add your control notification handler code here
UpdateData(FALSE); //必须是FALSE
CBtsInfo btsSet; //自己定义的类,继承CRecordset,与表BTS相关联
CString sql = "select * from bts";
btsSet.Open(AFX_DB_USE_DEFAULT_TYPE, sql);
while(!btsSet.IsEOF())
{
btsSet.MoveNext();
CString name = btsSet.m_BtsName;
m_BTS.AddString(name);
}
btsSet.Close();
}
获得Combo中的点击项:
CString btsName;
GetDlgItem(IDC_COMBO_BTSName)->GetWindowText(btsName); //获得组合框中的选中内容
初始化Combo中的项
void TraffStatisticDlg::OnDropdownCOMBOEndHour()
{
// TODO: Add your control notification handler code here
CString str;
int i;
for(i=0; i<24; i++)
{
str.Format("%d", i);
( (CComboBox *)GetDlgItem(IDC_COMBO_EndHour) ) -> AddString(str);
}
}