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

How to Dynamically Populate a List Box at Runtime.

How to Dynamically Populate a List Box at Runtime.

Summary

How to Dynamically Populate a List Box at Runtime.

Synopsis

The MSI tables must be modified at runtime in order to populate a listbox dynamically.
This can be done from an InstallScript Custom Action.

Discussion

Create an InstallScript Custom action and populate it with code like the examples below:

Call this function in Installscript to get a view of listbox items to make changes to:

MsiDatabaseOpenView(hDatabase, "SELECT * FROM ListBox", hView);

Iterate through the view to find last position of last item in list:
while ((MsiViewFetch(hView,hFetchRec) != ERROR_NO_MORE_ITEMS) && i<20)
i++;
//NumToStr(svString,i);
//MessageBox(svString,INFORMATION);
endwhile;

Then create a record to insert into the view that creates a new entry:
hRec = MsiCreateRecord(4);
MsiRecordSetString(hRec, 1, "TEST"); // Column1: Property tied to the entry
MsiRecordSetInteger(hRec, 2, i+1); // Column2: Display order of item
MsiRecordSetString(hRec, 3, svValue); // Column3: Value to set property to
MsiRecordSetString(hRec, 4, svDisplay); // Column4: Display text for item

Insert Record into the view:
MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec);

Close the view:
MsiViewClose(hView);



Additional Information

Attached is a sample project with a dialog that adds items to a listbox.
Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎May 19, 2018 01:00 PM
Updated by: