MDI and Child form
In this I have create menu item clicking on which a child form will be opened. if I click the same menu item again it will check for the form whether it is running or not. If it is running then it will display message that form is already open if form is not opened then it wil open the form.
MDIForm.vb
Public Class Form1 'Creating object of Form2 Dim a As New Form2 'Creating object of Form3 Dim b As New Form3 Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
'Val is variable in form2 which is of boolean type ' when the form wil be opened then it wil be true and when form wil be close it wil be false 'True indicates that form is already opened If a.val = True Then MsgBox("Form is already opened") Else 'False indicates that form is not opened so open the form2 a = New Form2 a.MdiParent = Me a.Show()
End If
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click 'Val is variable in form2 which is of boolean type ' when the form wil be opened then it wil be true and when form wil be close it wil be false 'True indicates that form is already opened If b.val = True Then MsgBox("Form is already opened") Else 'False indicates that form is not opened so open the form2 b = New Form3 b.MdiParent = Me b.Show()
End If
End Sub
End Class
Form2
Public Class Form2 Public val As Boolean
Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed val = False End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load val = True End Sub
End Class
Form3.vb
Public Class Form3 Public val As Boolean Private Sub Form3_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed val = False End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load val = True End Sub End Class
regards Check the attachement. Neetu
AttachmentsMDI and child Form (33460-3450-Messageifformopen.zip)
|
No responses found. Be the first to respond and make money from revenue sharing program.
|