Private Function ismdichi(ByVal chiformname As String) As Boolean
Dim chiform As Form
For Each chiform In Me.MdiChildren
If chiform.Name = chiformname Then
If chiform.Visible Then
chiform.Activate() '变成MDI应用系统中的当前活动窗体
Else
chiform.Show() '重新显示,并变成当前活动窗体
End If
Return True
End If
Next
Return False
End Function
Private Sub tianjiajilu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tianjiajilu.Click
If Not ismdichi("tjjl") Then
Dim chitianjiajilu As New tjjl
chitianjiajilu.MdiParent = Me '定义窗体的MDI父窗体
chitianjiajilu.Show()
End If
End Sub
通过以上代码可以打开N个相同子窗体。问:怎样才能使打开的子窗体成为当前唯一活动的子窗体?