Sometimes combo boxes have a large number of choices and it makes sense to allow users to enter their choice by typing the value. This cannot be done if the combo box has type drop down list. Change the type to drop down in the combobox style dialog. Now the list will be added to the listbox part of the box and the user may type in the edit box.
You set the current selection in the combo box to -1 (this indicates no current selection), add the strings to the combo box then execute the dialog. Upon return, if the user has used the pull-down box to pick a value that value will be returned by GetSelIndex. The value will be greater than or equal to -1. If the user types a value, the select index will still be -1. To find the item they selected, use the combo box function GetSelection will return the string in the edit box. Use the array class function find to get the location of the item. If find returns -1 that means no match was found.
void ComboWindow::cmTestCombo ()
{
// INSERT>> Your code here.
ComboDialogXfer tb;
Array backup;
backup.insertItem("First");
backup.insertItem("Second");
backup.insertItem("Third");
ArrayIterator next(backup);
while (next)
{
tb._combo.AddString(next().c_str());
next++;
}
tb._combo.Select(-1);
ComboDialog(&tb,this).Execute();
int which = tb._combo.GetSelIndex();
if ( which == -1)
{
string result = tb._combo.GetSelection();
which = backup.find(result);
}
char buff[255];
//strcpy(buff,result.c_str());
itoa(which,buff,10);
MessageBox(buff,"String Entered");
}
For complete code click here .