Sep 2, 2005 #1 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?
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?
Sep 3, 2005 2 #2 earthandfire Programmer Mar 14, 2005 2,924 GB 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. Upvote 0 Downvote
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.
Sep 11, 2005 Thread starter #3 557 Programmer Oct 25, 2004 64 US Thanks a lot earth and fire. I could use this tip for many form related issues I was facing. Upvote 0 Downvote