以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于更改目录树数据问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=147373) |
-- 作者:裴保民 -- 发布时间:2020/3/15 9:45:00 -- 关于更改目录树数据问题 修改或添加目录树项目时怎么控制不让有重复字段呢? |
-- 作者:有点蓝 -- 发布时间:2020/3/15 20:46:00 -- 到这个事件获取名称,http://www.foxtable.com/webhelp/topics/2404.htm 然后查表,或者遍历所有目录树节点判断是否有重复
|
-- 作者:裴保民 -- 发布时间:2020/3/15 21:07:00 -- 保存按钮代码如下? Dim dt As DataTable = DataTables("收入分类") Dim dic As New Dictionary(of Integer, Integer) Dim prevLevel As Integer = 0 Dim idxs As String = "-1," For Each nd As WinForm.TreeNode In e.Form.Controls("srflTreeView").AllNodes If nd.Level = 0 AndAlso dic.count > 0 Then Dim temp = dic(0) dic.Clear dic.Add(0, temp) End If If dic.ContainsKey(nd.Level) = False Then dic.Add(nd.Level, 1) Else dic(nd.Level) = dic(nd.Level) + 1 End If For i As Integer = nd.level + 1 To prevLevel dic(i) = 0 Next prevLevel = nd.Level Dim ndr As DataRow If nd.DataRow IsNot Nothing Then \'ndr = dt.Find("SRID = \'" & nd.DataRow("SRID")) ndr = dt.Find(" SRID = \'" & nd.DataRow("SRID") & " \'") \'字符列使用单引号 \'Dim idx As Integer=t.findrow("机具条码= \'" & str & "\' and _Identify <> " & t.current("_Identify")) Else ndr = dt.AddNew End If idxs &= "\'" & ndr("SRID") & "\'," Dim str As String = "" For i As Integer = 0 To nd.Level str &= format(dic(i), "000") & "." Next ndr("收入分类代码") = str.TrimEnd(".") ndr("收入目录") = nd.Text Next dt.DeleteFor("SRID not in (" & idxs & ")") dt.Save 想要的结果如下图?怎么修改代码? |
-- 作者:有点蓝 -- 发布时间:2020/3/15 23:13:00 -- 不好控制,建议在编辑完节点的时候就判断并保存 |
-- 作者:裴保民 -- 发布时间:2020/3/15 23:25:00 -- 如果有重复怎么禁止离开节点呢? 还有一个为题在AfterEditNode事件中下面的代码可以查出重复值,如果在按钮中编写代码,怎么查呢?如果重复,选中该节点, Dim trv As WinForm.TreeView=e.Form.Controls("zcflTreeView") For Each nd As WinForm.TreeNode In trv.AllNodes If nd.FullName <> e.Node.FullName AndAlso nd.Text = e.NewText Then msgbox("重复") e.Cancel = True trv.Select() trv.BeginEdit() End If Next [此贴子已经被作者于2020/3/15 23:39:34编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/3/15 23:42:00 -- 设置SelectedNode:http://www.foxtable.com/webhelp/topics/0884.htm |
-- 作者:裴保民 -- 发布时间:2020/3/15 23:50:00 -- 还有一个为题在AfterEditNode事件中下面的代码可以查出重复值,如果在按钮中编写代码,怎么查呢?如果重复,选中该节点, Dim trv As WinForm.TreeView=e.Form.Controls("zcflTreeView") For Each nd As WinForm.TreeNode In trv.AllNodes If nd.FullName <> e.Node.FullName AndAlso nd.Text = e.NewText Then msgbox("重复") e.Cancel = True trv.Select() trv.BeginEdit() End If Next |
-- 作者:有点蓝 -- 发布时间:2020/3/16 8:29:00 -- Dim trv As WinForm.TreeView=e.Form.Controls("zcflTreeView") For Each nd As WinForm.TreeNode In trv.AllNodes If nd.FullName <> e.Node.FullName AndAlso nd.Text = e.NewText Then msgbox("重复") e.Cancel = True trv.SelectedNode = nd trv.BeginEdit() return End If Next
|
-- 作者:裴保民 -- 发布时间:2020/3/16 9:14:00 -- 写在按钮中判断是错误的没有e.NewText [此贴子已经被作者于2020/3/16 9:15:26编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/3/16 9:18:00 -- Dim trv As WinForm.TreeView=e.Form.Controls("zcflTreeView") For Each nd As WinForm.TreeNode In trv.AllNodes For Each nd2 As WinForm.TreeNode In trv.AllNodes If nd.FullName <> nd2.FullName AndAlso nd.Text = nd2.Text Then msgbox("重复") trv.SelectedNode = nd trv.BeginEdit() Return End If Next Next
|