PDA

View Full Version : ComboBox bug???


Davide It
12-05-2007, 06:29 AM
Hello everybody.
My suspect is the following is a bug of AMS 7.

I wanted to use a ComboBox to select among three items. I wanted also to display some text in two labels, according to the selected item.
That's how I wrote down the code.
In On Startup section tAppName (table) and bIsDebug (boolean) are initialized, according to ini file values (boolean variable is set to true).

In Global Functions section the following function is present.
function ShowDebugMessage( sInString )
if bIsDebug then
Dialog.Message( "Debug", sInString );
end
end

In On Preload section of a given Page, the following instructions are present.
ShowDebugMessage( "Press OK to continue" );
ComboBox.ResetContent( "CoBAppName" );
for i = 1, Table.Count( tAppName ), 1 do
ComboBox.AddItem( "CoBAppName", tAppName[ i ], "" );
end

If ShowDebugMessage is invoked, CoBAppName ComboBox is correctly initialized.
Vice-versa, if I comment that function, all items of ComboBox are blank!!!
Why? I just cannot understand.
I moved around the obstacle using a ListBox instead of a ComboBox (it works!), but I am still curious...

Thanks to everyone that will try to help me.

azmanar
12-05-2007, 08:27 AM
Hi,

Have you tried switching the codes from the Page OnPreload to Page OnShow?

Dermot
12-05-2007, 09:43 AM
You can't add items to a ComboBox in the On Preload event. You must do it in the On Show event.

Davide It
12-05-2007, 11:51 AM
Dermot, azmanar, you are right!!!

It just works moving that portion of code from On Preload to On Show event.

But I can tell you this: since I started learning and using AMS, I am used to write code in On Preload event as much as I can. (The final effect is more elegant, to me.)
And, believe me, I made a working application in AMS 6 with a similar portion of code in On Preload event!

That's why I was thinking to a bug of AMS 7...

Thanks a lot anyway, you guys were very fast!!!

azmanar
12-05-2007, 01:06 PM
Hi Davide,

I learnt it from Dermot. :D