cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zakirulq
Level 2

Need to Populate ComboBox data

Hi,

I am working in Basic MSI project. I am trying to populate a combo box from a List of string. I read that CtrlGetText() will not work with basic msi. Then can anyone please help me that how i can populate a combo box runtime from a list of string.

Zaq
Labels (1)
0 Kudos
(2) Replies
zakirulq
Level 2

Hi,

I find a lot and finally make a solution which is correct or not i dont know.

You need to create a custom action and need to map this function to this custom action.

export prototype PopulateListCombo(HWND);
//PopulateCombo
function PopulateListCombo(hMSI)
LIST StringList;
STRING svString, sPath;
NUMBER nResult, nPath;
NUMBER hDatabase, hCBOView, hView, hRec;
STRING szText;
number index, nCount;
STRING sQuery;
begin
index=0;
hDatabase=MsiGetActiveDatabase(hMSI);

sQuery="SELECT * FROM ComboBox WHERE Property='PROPNAME'";
nResult = MsiDatabaseOpenView(hDatabase,sQuery,hCBOView);
hRec=MsiCreateRecord(4);

StringList = ListCreate (STRINGLIST);
ListAddString(StringList,"ZAQ",AFTER);
ListAddString(StringList,"FAK",AFTER);
ListAddString(StringList,"MAM",AFTER);

nResult = ListGetFirstString (StringList, svString);
MsiRecordSetString(hRec,1,'TESTPROP');
MsiRecordSetInteger(hRec,2,index);
MsiRecordSetString(hRec,3,svString);
MsiRecordSetString(hRec,4,svString);

MsiViewModify(hCBOView,MSIMODIFY_INSERT_TEMPORARY,hRec);
nResult = ListGetNextString (StringList, svString);

while (nResult != END_OF_LIST)
index=index+1;
MsiRecordSetString(hRec,1,'TESTPROP');
MsiRecordSetInteger(hRec,2,index);
MsiRecordSetString(hRec,3,svString);
MsiRecordSetString(hRec,4,svString);

MsiViewModify(hCBOView,MSIMODIFY_INSERT_TEMPORARY,hRec);
nResult = ListGetNextString (StringList, svString);
endwhile;

MsiCloseHandle(hRec);
MsiViewClose (hView);
end;


Remember to put your combo box Property name in to this line, Instead of TESTPROP.
MsiRecordSetString(hRec,1,'TESTPROP');;


I hope this will save some of your time.

/Zaq
0 Kudos
kiran4545
Level 3

I have got a case where i need to remove my combobox item during runtime. Is there a way where i can do it? I have been struggling to get this work from many days

Use case:

I have got a combobox and i have selected one item from it to do some customaction. In the next dialog i want the combobox item to get removed because i have already used it. So the remaining items needs to show apart from the one i have selected in the previous dialog. 

Is there any piece of code which can make this work ?

Any help is highly appreciated .

0 Kudos