我需要按名称关闭表单 我写过一个用于识别所选表格的探测器
Public Function GetActive ()
For Each form As DockContent In DockPanel1.Contents
If form.DockHandler.Pane.ActiveContent.DockHandler.Form.Name.ToString () = form.Name.ToString () Then
Dim FormName As String = form.Name.ToString ()
Return formName
end If
next
Return Nothing
End Function
我需要在路上写点什么
Dim clfrm As String = GetActive
clfrm.Close()
感谢您的回复
//对不起我的坏人。
答案 0 :(得分:1)
你的意思是这样吗?
Public Function CloseForm(name As String) As Boolean
For Each form As DockContent In DockPanel1.Contents
If form.DockHandler.Pane.ActiveContent.DockHandler.Form.Name = form.Name Then
If form.Name = name Then
form.Close()
Return true
End If
End If
Next
Return false
End Function
(未测试的)