I've got ComboBox with three entries from a StringList.
Now I wish to programmatically add an entry:
comboBoxDiP = mdlDialog_itemGetByIndex(GetDialog(), 7); if (comboBoxDiP) { wprintf(L"Got it\n"); // test to insert a value StringListP strListP = mdlDialog_comboBoxGetStrListP(comboBoxDiP->GetRawItem()); if (strListP) { // add an item into the string list long newIndex; mdlStringList_insertMember(&newIndex, strListP, -1, 1); wprintf(L"newIndex=%d\n", newIndex); long result = mdlStringList_setMember(strListP, newIndex, L"999.0", NULL); wprintf(L"result=%d\n", result); ErrorCode ec = mdlDialog_comboBoxSetStrListP(comboBoxDiP->GetRawItem(), strListP, 1); wprintf(L"ec=%d\n", ec); } } else
Once the code runs, this is what the ComboBox look like when opened:
This is the "output" of the print statements, showing everything went OK...
Any idea where I've gone astray?
Bruce
I just removed the last part of the code:
//ErrorCode ec = mdlDialog_comboBoxSetStrListP(comboBoxDiP->GetRawItem(), strListP, 1); //wprintf(L"ec=%d\n", ec);
and now I get what I expected....
Bruce Reeves SRNS said:I've got ComboBox with three entries from a StringList
Prefer to use a ListModel. StringLists are soo 20th century.
ListModel
StringList
ListModels are more versatile and it's much easier to create multiple columns than when using a StringList.
Regards, Jon Summers LA Solutions