以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何目录树添加列表数据 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=133502) |
||||
-- 作者:yfy13338431925 -- 发布时间:2019/4/15 12:48:00 -- 如何目录树添加列表数据 甜老师,以下是帮助文件中的代码,要继续添加四类、五类做不来,提示一下 增加子节点”按钮的Click事件代码: Dim tr As WinForm.TreeView |
||||
-- 作者:有点甜 -- 发布时间:2019/4/15 12:56:00 -- 参考
|
||||
-- 作者:yfy13338431925 -- 发布时间:2019/4/15 13:31:00 -- 甜老师,这样的表太不直观了吧,我想做成帮助文件中的,帮我看看,如何插入四、五类的子节点 |
||||
-- 作者:HerderYE -- 发布时间:2019/4/15 13:52:00 -- Dim tr As WinForm.TreeView Dim nd As WinForm.TreeNode tr = e.Form.Controls("TreeView1") nd = tr.SelectedNode If nd IsNot Nothing Then If nd.Level = 3 Then MessageBox.Show("最多允许四层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Else Dim dr As DataRow = DataTables("表A").AddNew If nd.Level = 0 Then dr("大类") = nd.Text dr("二类") = "新节点" ElseIf nd.Level = 1 dr("大类") = nd.ParentNode.Text dr("二类") = nd.text dr("三类") = "新节点" ElseIf nd.Level = 2 dr("大类") = nd.ParentNode.ParentNode.Text dr("二类") = nd.ParentNode.text dr("三类") = nd.text dr("四类") ="新节点" End If nd = nd.Nodes.Add("新节点") tr.SelectedNode = nd tr.Select() tr.BeginEdit() End If End If
|
||||
-- 作者:HerderYE -- 发布时间:2019/4/15 13:53:00 -- 当然,要把表A的第4列修改为“四类”,AfterEditNode事件代码对应调整: If e.NewText = "" Then e.Cancel = True Return End If Dim pth() As String = e.Node.FullPath.Split("\\") Select Case e.node.Level Case 0 DataTables("表A").ReplaceFor("大类",e.NewText,"大类 = \'" & pth(0) & "\'") Case 1 DataTables("表A").ReplaceFor("二类",e.NewText,"大类 = \'" & pth(0) & "\' And 二类 = \'" & pth(1) & "\'") Case 2 DataTables("表A").ReplaceFor("三类",e.NewText,"大类 = \'" & pth(0) & "\' And 二类 = \'" & pth(1) & "\' And 三类 = \'" & pth(2) & "\'") Case 3 DataTables("表A").ReplaceFor("四类",e.NewText,"大类 = \'" & pth(0) & "\' And 二类 = \'" & pth(1) & "\' And 三类 = \'" & pth(2) & "\' And 四类 = \'" & pth(3) & "\'") End Select e.Node.Name = e.NewText |
||||
-- 作者:有点甜 -- 发布时间:2019/4/15 15:11:00 -- 必须这样做
|
||||
-- 作者:yfy13338431925 -- 发布时间:2019/4/15 15:53:00 -- 前面的方法测试,显示结果错误,呈梯形。是不是只能用您给的例子了? |
||||
-- 作者:有点甜 -- 发布时间:2019/4/15 16:03:00 -- 以下是引用yfy13338431925在2019/4/15 15:53:00的发言:
前面的方法测试,显示结果错误,呈梯形。是不是只能用您给的例子了?
你这种不好控制,必须用6楼的这种方式。 |