各位老师,
为了方便查看,我用下面的代码实现三个目录树窗口中的表同步显示,但若其中的一个目录树中没有其他目录树中的表时就提示出错,
此主题相关图片如下:360截图20121120-001.jpg

AfterSelectNode的代码为:
Dim tr2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim tr3 As WinForm.TreeView = e.Form.Controls("TreeView3")
Dim tr_Flow As WinForm.TreeView = e.Form.Controls("tr_Flow")
'定义一个字符型变量nd保存父节点的标题值
Dim nd As String
If e.Node.Level = 0 Then
nd = e.Node.Text
Else
nd = e.Node.ParentNode.text
End If
'在其他目录树窗口中同步显示当前所先选节点的表及列.
Dim nd2 As WinForm.TreeNode = tr2.Nodes(nd)
If nd2 IsNot Nothing Then
Dim idx2 As Integer = Math.MIn(12, nd2.Nodes.Count - 1)
tr2.SelectedNode = nd2
nd2.Nodes(idx2).EnsureVisible
End If
Dim nd3 As WinForm.TreeNode = tr3.Nodes(nd)
If nd3 IsNot Nothing Then
Dim idx3 As Integer = Math.MIn(12, nd3.Nodes.Count - 1)
tr3.SelectedNode = nd3
nd3.Nodes(idx3).EnsureVisible
End If
红色的代码就是想实现其他目录树窗口中有存在同名的表时才执行,但为什么还提示出错呢?
谢谢!
[此贴子已经被作者于2012-11-20 16:45:24编辑过]