Getting form to run its load event without showing form

S

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
 
W

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 ([email protected], 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.
 
G

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
 
S

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top