Public Class MainMDI
Public Sub ShowForm(Of FormType As {Windows.Forms.Form, New})()
Try
For Each ChildForm As Form In Me.MdiChildren
If TypeOf ChildForm Is FormType Then
ChildForm.Focus()
Exit Sub
End If
Next
Dim frm As New FormType
frm.MdiParent = Me
frm.Show()
Catch ex As Exception
' แสดงข้อผิดพลาด
End Try
End Sub
Private Sub miTestForm_Click(sender As System.Object, e As System.EventArgs) Handles miTestForm.Click
Me.ShowForm(Of TestForm)()
End Sub
End Class