This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- How to Dynamically Populate a List Box at Runtime.
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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.
No ratings