On Tue, 14 Oct 2003 08:09:06 -0700, "Ivan" <Iv*****@aol.com> wrote:
I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?
I tend to think of forms as just another class just with ui objects
As with all classes you can add a handler to a class event.
Now when you inherit from Inherits System.Windows.Forms.Form
you class gets an Closing event. I would just create a function that
can handle the second class's Closing event
kinda like this
'In Main Form
Dim login As New Login()
AddHandler login.Closing, AddressOf Login_UnLoad
login.ShowDialog(Me)
Me.Visible = False
No further down in the main form class I would have this
Private Sub Login_UnLoad(ByVal sender As System.Object, ByVal e As
System.ComponentModel.CancelEventArgs)
'Perform Business Logic
Me.Visible = True
End Sub
now when the login form is unloaded it will raise an event of Closing
and my procedure that I added the handler to will catch that event and
procede wiht making my main form visible again