C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

MDI and child Form


Posted Date: 03 Oct 2009    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: NeetuMember Level: Diamond    
Rating: 1 out of 5Points: 8



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

Attachments

  • MDI and child Form (33460-3450-Messageifformopen.zip)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Winforms  .  Windows application  .  MDIForm and Child form  .  MDI form  .  MDI  .  Child form  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Dealing with timer
    Previous Resource: Find Driver Details in VB.NET
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use