Home All Groups Group Topic Archive Search About

Getting form to run its load event without showing form

Author
5 Jul 2006 7:17 AM
steve
Hi All

I need help on how to load a form in the background so the load event runs
(only once) then I can pass data and call showdialog

I have code in the forms load event which populates comboboxes etc

I then want to select a particular combobox index and call routines within
the form before showing it dialog

I currently call form.show then form.hide, pass the data as required then
call form.showdialog

I notice the form load event fires on both form.show and form.showdialog


Regards
Steve

Author
5 Jul 2006 9:46 AM
Walter Wang [MSFT]
Hi Steve,

Thank you for your post.

I think you can just put your initialization code in the constructor of
your form, just make sure the InitializeComponent() is called first:

    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
    End Sub

Then you don't need to call Show(), Hide() again; just new the form object,
pass some data, and call ShowDialog().   

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
7 Jul 2006 6:08 AM
GhostInAK
Hello Walter Wang [MSFT],

> Then you don't need to call Show(), Hide() again; just new the form
> object, pass some data, and call ShowDialog().


Just new the form!!?  Geez.. No wonder VB programmers get a bad rap.. and
yer a Microsoft employee!!  Geezus!

It's called instantiation for those of you speaking ghetto-talk.  You instantiate
an object.

-Boo
Author
7 Jul 2006 6:12 AM
Steven Nagy
Walter's solution makes more sense.
The code that needs to be executed when the form is created needs to go
in the constructor, not the form_load.