'Check if MDI Form have children
If Me.HasChildren Then
'Loop through all the mdi child and check the type of form if it matches
'the type of the form that you wanted to have only 1 instance then
'move the focus to that child form and exit
For Each ChildForm As Form In Me.MdiChildren
If TypeOf ChildForm Is frmSystemSettings Then
ChildForm.Focus()
Exit Sub
End If
Next
End If
'No instance of the form was found
'create one and add to mdi children
'lastly show the form
Dim SettingsForm As New frmSystemSettings
SettingsForm.MdiParent = Me
SettingsForm.Show()
i added the above code under the Click event of the OptionsToolStripMenuItem which i wanted to load only a single instance of a form
No comments:
Post a Comment