469,958 Members | 1,986 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

Getting form to run its load event without showing form

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
Jul 5 '06 #1
3 3428
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 (wa****@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.

Jul 5 '06 #2
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
Jul 7 '06 #3
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.

Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Matthew Wells | last post: by
3 posts views Thread by Cc | last post: by
3 posts views Thread by John | last post: by
3 posts views Thread by Dennis | last post: by
4 posts views Thread by DBC User | last post: by
4 posts views Thread by Kimmo Laine | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.