[Gambas-user] Form Open code skipped when using Form1 = New Form syntax.

Tobias Boege taboege at ...626...
Sun May 10 19:36:36 CEST 2015


On Sun, 10 May 2015, Martin McGlensey wrote:
> Hello,
> 
> I have a form (form) that has several controls on it. They are comboboxes,
> textboxes and buttons. The comboboxes are initialized in the form open
> procedure.
> 
> If I open a new form using "Form1 = New form" and call it from another form
> the dropdown list of the comboboxes as well other variables are not
> initialized on Form1. This should occur when the form opens but, in the NEW
> instance the form open routine appears to be skipped. Of course without the
> data contained in the comboboxes the code in the NEW instance fails.
> 
> Is there a way around this? How can I force the new instance (Form1) to
> initialize properly?
> 

It is intended that the form is *not* shown as soon as it is instantiated.
If you want to do that, just write

  Form1 = New form
  Form1.Show()

Or alternatively, if you want to initialise children independent of whether
the form is shown or not, you write the initialisation code into the
constructor of your "form" class which is the special _new method[0].

Regards,
Tobi

[0] http://gambaswiki.org/wiki/lang/special/new

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list