Setting the selectedLabel in a dropDown on loading a window

This seems like a simple task but I can not get this to work. I have a dropdown on a window that has values 1 to 12 in it. I load the the value I need to show as the currently selected value from the database on the internalFrameActive event that gets fired when the window is opened.

I use the following to set the label of the dropdown: event.source.rootContainer.getComponent(‘dropDown1’).selectedLabel = str(dbValue)

but this does not work. I also tried:
event.source.rootContainer.getComponent(‘dropDown1’).selectedIndex = dbValue

also:

event.source.rootContainer.getComponent(‘dropDown1’).selectedValue = dbValue

also:

event.source.rootContainer.getComponent(‘dropDown1’).selectedStringValue = str(dbValue)

nothing works. I am assuming that setting the label on a dropdown is possible.

The dropbox is set to lenient

You should just bind the selectedStringValue property of the dropdown to a SQL query. You can set the query to polling off to run just once when the window is activated.

If you don’t want to do that, the problem is that the internalFrameActivated event fires before all binding occurs. You want that code to fire after the current processing takes place, so you need to wrap it up with an invokeLater function:def doLater(event=event, dbValue=dbValue): event.source.rootContainer.getComponent('dropDown1').selectedStringValue = str(dbValue) system.util.invokeLater(doLater)

I tried that and it also does not work.

Also, according to the manual:

"Internal frame events are fired by windows. (They are known as “internal frames” in the underlying Java windowing system that the Vision component uses). Note that the source of these events is the window itself. To get the root container of the window, use event.source.rootContainer, not event.source.getComponent(“Root Container”).

The Activated/Deactivated events get fired when the component receives or loses input focus. The Activated event is a more reliable event to use as a window startup event than the Opened event, because the Opened event will not be called if the window was opened when it was already cached."

Based on this advice from the manual I would assume that you can populate a window with information when it is loaded.

Yes, you can. Do you have the selectedStringValue of the dropdown bound to something else? You can post a small example so we can take a look at it?