Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form enabling/disabling 2

Status
Not open for further replies.

557

Programmer
Oct 25, 2004
64
US
suppose I have 2 forms. I need to call 2nd form from 1st form.

when frm2.show() is given, I want to disable frm1. and when frm2 is closed, i need to enable frm1 again. How do I do this?


 
When you say disable do you mean that frm1 should still be visible but just not accessible?

If so then the easiest way is to use frm2.ShowDialog


If you want frm1 to be hidden until frm2 closes then you need something like:

In Form1:

Dim frm2 As New Form2(Me)
frm2.Show()
Me.Visible = False

and in Form2:

#Region " Windows Form Designer generated code "

Public Sub New(ByVal CalledBy As Form1)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

MyParent = CalledBy

'Add any initialization after the InitializeComponent() call

End Sub
..
..
..
#End Region

Private MyParent As Form1

Private Sub Form2_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

MyParent.Visible = True

End Sub

Hope this helps.
 
Thanks a lot earth and fire. I could use this tip for many form related issues I was facing. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top