|
-
Sep 21st, 2006, 03:54 AM
#1
Thread Starter
Member
Close Form
Hi All,
I created a sub form and in the procedure "Public Sub New()" I'll do some checks.
If the checks are ok the form will be visible, if not, how do I close the window without any error messages and return back to the main form.
Thanks,
AXH
-
Sep 21st, 2006, 04:06 AM
#2
Re: Close Form
 Originally Posted by ahollaar
Hi All,
I created a sub form and in the procedure "Public Sub New()" I'll do some checks.
If the checks are ok the form will be visible, if not, how do I close the window without any error messages and return back to the main form.
Thanks,
AXH
Hi,
Try this;
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Wkr,
sparrow1
-
Sep 21st, 2006, 04:09 AM
#3
Thread Starter
Member
Re: Close Form
The window isn't visible yet.
I want to close the window before it will be visible
-
Sep 21st, 2006, 04:22 AM
#4
Hyperactive Member
Re: Close Form
Hi,
Just on the new event
call the me.close or me.dispose method (as you need)
Hope this helps
-
Sep 21st, 2006, 04:35 AM
#5
Re: Close Form
The constructor has nothing whatsoever to do with the form becoming visible. It doesn't make the form visible and it can't the form becoming visible. Once the constructor has completed its then up to the creator whether to call Show or not, which is how the form becomes visible. if your form doesn't want to be shown then it needs to tell its creator not to show it. The most logical way to do this would be to provide a public, read-only, boolean property that indicates whether the checks you performed in the constructor were successful or not, e.g.
VB Code:
Private ReadOnly _initialised As Boolean = False
Public ReadOnly Property Initialise() As Boolean
Get
Return Me._initialised
End Get
End Property
Public Sub New()
'...
'For example.
Me._initialised = IO.File.Exists("some critical file")
End Sub
Your main form would create an instance and then check its Initialised property, only showing the form if it was True.
Having said that, it would be preferable to perform the checks in the main form before even creating the form instance if that's practical. Why create a form if you're never going to use it?
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
|