thenefield
Posts: 68
Joined: Thu Dec 06, 2007 6:19 pm

Dynamically Populate ComboBox via VBS

Hi,

I would like to update my combo box during initialization.

I have created a simple test script to do this:

-----------------BEGIN-----------------

Dim MsiDb
Dim MsiInstall
Dim MsiRecord
Dim MsiView

Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")
Set MsiRecord = MsiInstall.CreateRecord(4)
MsiRecord.StringData(1) = COMBOBOX
MsiRecord.IntegerData(2) = 1
MsiRecord.StringData(3) = VALUE
MsiRecord.StringData(4) = TEXT
Call MsiView.Execute(MsiRecord)
Call MsiView.Modify (7, MsiRecord)
Call MsiView.Close

-----------------END-----------------

I have this script included as a UI custom action and I have have inserted the script via a DoAction in the init events for the dialog in question.

The COMBOBOX in StringData(1) is the property name of my combo box.

However, it doesn't seem to work.

Any ideas?

Thanks.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Please note that you are not performing the query correctly. You need to use "INSERT INTO" instead of "SELECT FROM".

There are discussions about this on the forum, please take a look:
http://www.advancedinstaller.com/forums ... php?t=4636
http://www.advancedinstaller.com/forums ... php?t=1768
http://www.advancedinstaller.com/forums ... php?t=5130

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
thenefield
Posts: 68
Joined: Thu Dec 06, 2007 6:19 pm

Thanks for the reply Cosmin.

I don't know why, but it seemed to work when I did the following:

--------------------BEGIN------------------------

dim ODB: set ODB = Session.Database
dim oInstaller: set oInstaller = Session.Installer
Set view = ODB.OpenView("Select * From `ComboBox`")
dim i : i = 0
i = i + 1
view.Execute
Set mrecord = oInstaller.CreateRecord(4)
mrecord.StringData(1) = "COMBOBOX"
mrecord.IntegerData(2) = i
mrecord.StringData(3) = "something"
mrecord.StringData(4) = "something else"
view.Modify 7, mrecord
view.Close

----------------------END--------------------------

The code in the links you provided seemed to work as well. Do you know what the difference is between these two methods?

Thanks,

Trey
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Predefined CAs for working with ComboBox and ListBox control

Hi,

Starting with version 6.3, AI includes predefined Custom Actions for populating, deleting from and extracting data from ComboBox and ListBox controls.

You will find a tutorial and sample projects in the AI help file or online user guide.

For any questions or comments do not hesitate to contact us at support at advancedinstaller dot com.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
thenefield
Posts: 68
Joined: Thu Dec 06, 2007 6:19 pm

Re: Dynamically Populate ComboBox via VBS

I am using the aucustact.dll to perform PopulateComboBox to populate my combobox which works great initially.

My combobox is based upon a list of software configuration profiles available. So now I have had the idea to include a pushbutton just above my combobox to invoke the configuration wizard so that if no configuration profile is found or a new profile is desired, then the configuration wizard can be called upon directly from the installer.

This idea works great if no profiles were previously defined leaving the combobox empty. However if the combobox has already been populated with a list of profiles that had already been created, then the new profile created with my configuration wizard does not instantly get added to the combobox. I have checked my AI_COMBOBOX_DATA field and it is getting updated with the new profile created. But it appears that PopulateComboBox does not perform this change.

Any thoughts on what I am doing wrong?

Thanks!

--- UPDATE ---

Ok I realized it was due to duplicate items upon repopulating. Is there any simple way to clear out the combobox before repopulating?

--- UPDATE 2 ---

Ok, I found the solution.

I first pull the AI_COMBOBOX_DATA and determine if it is empty or not. If it is empty then I proceed as normal. If it is not empty then I make calls to DeleteFromComboBox, as demonstrated in the example scripts provided by Advanced Installer, to clear out the combobox and then proceed to repopulate the comobox. Works like a charm now.

Return to “Common Problems”