codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Populating Combobox

Hello,

I'm trying to use the SQL Database Browse functionality to populate a combobox with a list of databases when the user clicks the combobox drop down arrow. Consider the attached example.
dialog.PNG
dialog.PNG (41.38 KiB) Viewed 4677 times
Everything works if the sql browse execution (and respective dialog refresh) is tied to the "Search" button. However, if I tie them to the combobox control, the databases don't seem to get loaded into the combobox correctly. Only a single database is loaded into the combobox, even though the listbox above it is populated with all the databases in the SQL server (I have the listbox tied to the same sql browse execution as the combobox). So, it's clear that the databases exist and can be found, but I don't understand why they aren't being loaded into the combobox correctly. Is this a bug? I experienced the same (or similar) issue when trying to use the method here. Possibly related to this post.


Thanks.
Attachments
PopulateComboBox.zip
(3.58 KiB) Downloaded 230 times
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Populating Combobox

Hello,

First of all, thank you for the provided test project, it was really helpful.

I have investigated it and I found some problems:

1. you always populate the combobox when the ComboBox is pressed
2. you always refresh the dialog

Basically, the user can not even see what is inside the ComboBox becuase you always refresh the dialog, resulting in the ComboBox control also refreshing.

To avoid that, we have to only populate the ComboBox once and also refresh the dialog only once.

In order to stop populate the ComboBox, we need to stop re-executing the custom action everytime the button is pressed.

Here is how you can resolve both of the problems presented above:
conditions.png
conditions.png (73.98 KiB) Viewed 4664 times

As you can see, we have added a condition to the execution of the custom action to execute only if the ListBox is empty. After the ListBox is populated, the custom action will no longer be executed when the ComboBox is pressed.

Additionally, we have set a property that we have used to condition the execution of the "Refresh the current dialog" event. Basically:

- we populate both the combobox and the listbox

- we refresh the dialog

- we set the property

- when the combobox is pressed again, the installer will check:

Is DATABASE2 prop empty?
Ans: No!
==> the custom action will no longer run

Is the (AI_INSTALL AND (NOT STOP_REFRESH = "True")) evaluated as true?
Answ: No!
==> the refresh will no longer happen

Please find attached a copy of your .AIP file with the modifications I have mentioned above:
PopulateComboBox.aip
(17.79 KiB) Downloaded 238 times

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Populating Combobox

Thank you for the detailed response Catalin. The combobox does work with the fixes you described. However, the issue I'm seeing now is that you must click the combobox drop down arrow twice to see the list of databases. It appears that the following happens:
  1. Click the drop down arrow on the combobox.
  2. The "ShowDatabases" custom action runs and finds all the databases.
  3. The dialog is refreshed.
  4. The refresh prevents the combobox from expanding from the first click, so you have to click the combobox drop down arrow a second time.
  5. "ShowDatabases" and the dialog refresh don't execute (as expected)
  6. The combobox expands, displaying the list of databases.
Is there anyway to resolve this?


Thanks.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Populating Combobox

Hello,

Indeed, you are right.

Unfortunately, I am afraid it is not possible to avoid that, if we want to execute the custom action from the ComboBox control, since we need to refresh the dialog.

The only thing that can be done here, I believe, is to execute the custom action from a "PushButton" control.

Hope this helps somehow.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”