请老师帮忙看一下 软件升级到最新版后 之前定义(红色部分)的都不能用了
Public Function FindWindow(ByVal Title As String) As System.Windows.Forms.Form
Dim frmFormManager As System.Windows.Forms.Form
For Each frm As System.Windows.Forms.Form In Application.OpenForms
If frm.Text=Title Then
frmFormManager=frm
frm.BringToFront
Return frm
End If
Next
Return Nothing
End Function
Public Sub GetNode(ByVal strWinName As String, ByRef lstNodes As System.Windows.Forms.TreeNodeCollection)
For Each tNode As System.Windows.Forms.TreeNode In lstNodes
If tNode.Text = strWinName Then
tNode.TreeView.SelectedNode = tNode
Exit For
End If
GetNode(strWinName, tNode.Nodes)
Next
End Sub
Public Sub FindAndShowWindow(ByVal strFormName As String)
Dim frmManager As System.Windows.Forms.Form=FindWindow("窗口管理")
If frmManager Is Nothing Then
frmManager=New FormsManager()
Dim intTop As Integer
Dim trv As System.Windows.Forms.TreeView = frmManager.controls("TreeView1")
trv.Dock= System.Windows.Forms.DockStyle.None
trv.Anchor= System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Top
intTop= trv.Top
trv.Top=trv.Top+28
trv.Height=trv.Height-30
'trv.Bottom=3
Dim txtFilter As New System.Windows.Forms.TextBox
txtFilter.Name="txtFormFilter"
txtFilter.Top=intTop
txtFilter.Left= trv.Left
txtFilter.Width=200
frmManager.Controls.Add(txtFilter)
Dim btnFindNext As New System.Windows.Forms.Button
btnFindNext.Name="btnFindNext"
btnFindNext.Text="下一个"
btnFindNext.Top=intTop
btnFindNext.Left= txtFilter.Left+ txtFilter.Width +5
AddHandler btnFindNext.Click,AddressOf btnNextForm_Click
frmManager.Controls.Add(btnFindNext)
If strFormName IsNot Nothing AndAlso strFormName.Length>0 Then
GetNode(strFormName,trv.Nodes)
End If
frmManager.Owner= BaseMainForm
frmManager.ShowDialog()
Else
Dim trv As System.Windows.Forms.TreeView = frmManager.controls("TreeView1")
If strFormName IsNot Nothing AndAlso strFormName.Length>0 Then
GetNode(strFormName,trv.Nodes)
End If
frmManager.BringToFront
End If
End Sub
Public Sub btnNextForm_Click(sender As Object, e As EventArgs)
Dim btnFind As System.Windows.Forms.Button=CType(Sender,System.Windows.Forms.Button)
Dim frmManager As System.Windows.Forms.Form= btnFind.FindForm
Dim txtFormFilter As System.Windows.Forms.TextBox=CType(frmManager.controls("txtFormFilter"),System.windows.Forms.TextBox)
Dim strName As String = txtFormFilter.Text
If strName = "" Then
Return
End If
Dim trv As System.Windows.Forms.TreeView = CType(frmManager.controls("TreeView1"),System.windows.Forms.TreeView)
Dim Start As Integer
Dim idx As Integer = -1
Dim firstNode As System.Windows.Forms.TreeNode = Nothing
Dim _SelectNode As System.Windows.Forms.TreeNode= trv.SelectedNode
Dim blnFindPre As Boolean = False '标记是否在选择节点前发现Node
Dim blnPre As Boolean = True '表示目前在选择节点前搜索
If _SelectNode IsNot Nothing Then
Dim FullName As String = _SelectNode.FullPath
For Each nd As System.Windows.Forms.TreeNode In trv.Nodes
If nd.Text.ToUpper.Contains(strName.ToUpper) Then
If blnPre = True Then '如果是在选择节点前
If blnFindPre = False Then '如果没有找到过相应的结果
firstNode = nd
blnFindPre = True
End If
Else '如果是在选择节点后
nd.EnsureVisible()
_SelectNode = nd
trv.SelectedNode = nd
trv.Select()
Return
End If
End If
If nd.FullPath = FullName Then
blnPre = False
Start = nd.Index
End If
If nd.Nodes.Count > 0 Then
If CheckNextLevelNode(trv,nd, strName, FullName, Start, blnPre, blnFindPre, firstNode) = True Then '如果找到对应的子节点则退出
If blnPre Then
Continue For
Else
trv.Select()
Return
End If
End If
End If
Next
If blnFindPre AndAlso firstNode IsNot Nothing Then
firstNode.EnsureVisible()
trv.SelectedNode = firstNode
trv.Select()
Return
End If
Else
blnPre = False
For Each nd As System.Windows.Forms.TreeNode In trv.Nodes
If nd.Text.ToUpper.Contains(strName.ToUpper) Then
nd.EnsureVisible()
trv.SelectedNode = nd
trv.Select()
Return
End If
If nd.Nodes.Count > 0 Then
If CheckNextLevelNode(trv,nd, strName, "", Start, blnPre, blnFindPre, firstNode) = True Then '如果找到对应的子节点则退出
trv.Select()
Return
End If
End If
Next
End If
trv.Select()
End Sub
Private Function CheckNextLevelNode(ByRef trv As System.Windows.Forms.TreeView, ByRef ndFather As System.Windows.Forms.TreeNode, ByVal strName As String, ByVal FullName As String, ByRef Start As Integer, ByRef blnPre As Boolean, ByRef blnFindPre As Boolean, ByRef firstNode As System.Windows.Forms.TreeNode) As Boolean
For Each nd As System.Windows.Forms.TreeNode In ndFather.Nodes
If nd.Text.ToUpper.Contains(strName.ToUpper) Then
If blnPre = True Then '如果是在选择节点前
If blnFindPre = False Then '如果没有找到过相应的结果
firstNode = nd
blnFindPre = True
End If
Else '如果是在选择节点后
nd.EnsureVisible()
trv.SelectedNode = nd
Return True
End If
End If
If nd.FullPath = FullName Then
blnPre = False
Start = nd.Index
End If
If nd.Nodes.Count > 0 Then
If CheckNextLevelNode(trv,nd, strName, FullName, Start, blnPre, blnFindPre, firstNode) = True Then '如果找到对应的子节点则退出
Return True
End If
End If
Next
Return False
End Function