I need to create a combo box in MFC /VC++ in which user can enter or select values in between 0 to 9999 only. How can I acheive this functionality.
Please Help
I need to create a combo box in MFC /VC++ in which user can enter or select values in between 0 to 9999 only. How can I acheive this functionality.
Please Help
CComboBox* pCombo = (CComboBox*)GetDlgItem(IDS_COMBO1);
for (int i = 0; i < 9999; i++) pCombo->AddString(CString::Format(_T("%d"),i);
Try this:
CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
CWnd* pComboEdit = pCombo->GetWindow(GW_CHILD);
if (pComboEdit != NULL)
pComboEdit->ModifyStyle(0, ES_NUMBER);
Edit: In order to restrict the number of characters/digits:
((CEdit*)pComboEdit)->LimitText(4);