|
-
Nov 3rd, 2003, 11:06 PM
#1
Thread Starter
New Member
Loading a form without displaying it
I need to have a form load, but not display until it is ready (some maths heavy calculations need to be done before the form can display). As I understand it, the only way to trigger the load event in a form is by Form.Show(). Is there another way to do it without the form becoming visible? I have played around with Form.Activate(), but haven't had any luck yet.
Thanks,
Vulpes
-
Nov 3rd, 2003, 11:17 PM
#2
Why not set it's visable property to false, and then use form.show() and when ready, make it visable?
-
Nov 4th, 2003, 03:39 AM
#3
Why do you need the Form_Load event?
Any initialization code can go in the constructor. If you expand the 'Windows Form Designer generated code' region at the top of the form. Look for the constructor:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
Then just put your code in the spot it suggests after the InitializeComponent call.
-
Nov 4th, 2003, 04:46 AM
#4
just do something like this ...
VB Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
While DoStuff() = False
Application.DoEvents() '/// dont allow the Form to show till DoStuff = True.
End While
End Sub
Private Function DoStuff() As Boolean
MessageBox.Show("wait for form to load") '/// your stuff ToDo before Form shows goes here.
Threading.Thread.Sleep(5000) '/// 5 seconds in this case.
Return True
End Function

edit :
by the way you dont need to use Sleep when actually carrying out the function, that was just to demonstrate. you would do this...
VB Code:
Private Function DoStuff() As Boolean
'/// carry out the code before loading the form.
Return True
End Function
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 4th, 2003, 07:43 AM
#5
Fanatic Member
My vote and prefered method would be to do it in the constructor, as Edneeis suggested.
-
Nov 4th, 2003, 05:12 PM
#6
Thread Starter
New Member
Ah wonderful, thanks Edneeis. I am upgrading the program from VB6, and it didn't even occur to me to use the constructor instead of the load event. Thanks to everyone.
-Vulpes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|