Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
狐爸:
重命名树是有例子的,没有问题.
我现在点击某节点,弹出一修改窗,其中也修改节点名,这时存不到树里,只能存到表里.请看一下:
Dim tr As WinForm.TreeView = Forms("定位树").Controls("TreeView1")
Dim nd As WinForm.TreeNode = tr.SelectedNode
Dim td As winform.treenode
Dim id As Integer = nd.index
td = tr.nodes(id)
td.Text = Forms("修改树").Controls("TextBox1").text
Tables("商品").Current.Save()
tr.SelectedNode = nd '选择新插入的节点
tr.Select '选择目录树
来自于表就保存在表即可啊。
你做个简单的例子传上来,否则我无法理解。
下载信息 [文件大小: 下载次数: ] | |
![]() |
我写的代码:
Dim tr As WinForm.TreeView = Forms("定位树").Controls("TreeView1")
Dim nd As WinForm.TreeNode = tr.SelectedNode
Dim Vals() As String = e.Form.Controls("TextBox1").text.split("|")
For i As Integer = Vals.Length -1 To 0 Step - 1
nd.text = vals(i)
nd = nd.ParentNode
If nd Is Nothing Then
Exit For
End If
Next
Tables("商品").Current.Save()
你之前的代码毫无逻辑可言,你不会保存是正常的,但是逻辑完全混乱,你看看你的代码:
Dim tr As WinForm.TreeView = Forms("定位树").Controls("TreeView1")
Dim nd As WinForm.TreeNode = tr.SelectedNode
Dim td As winform.treenode
Dim id As Integer = nd.index
td = tr.nodes(id)
td.Text = Forms("修改树").Controls("TextBox1").text
Tables("商品").Current.Save()
tr.SelectedNode = nd '选择新插入的节点
tr.Select '选择目录树
第二行执行,nd是选定节点,你要改名的就是这个选定节点,你却绕这么大一个圈子找了一个完全不像干的节点td来改名。
而且不要以为td和nd的index属性相同,就是同一个节点,index表示节点在父节点集合中的位置,以下面这个图片为例:家电产品、电脑配件,服务器三个节点,他们的index属性都是2,却是三个完全不同的节点。
编程是严谨的,建议你从头到尾,细看两次帮助,否则你花的时间更多。
不要以为有个完整的例子就能帮到你,因为没有一个例子能将所有基本知识、所有的可能性、所有的控件涵盖进去。
我从不认为编程是一个有很高技术含量的工作,只是一项蓝领工作而已,我一直觉得,基本原理通了,其他都是“小菜”而已。
我接触过大量的客户,基本上越想快速上手的人越上不了手,最终花的时间更多。
不行,是因为手误,改一个字符就行了:
Dim tr As WinForm.TreeView = Forms("定位树").Controls("TreeView1")
Dim nd As WinForm.TreeNode = tr.SelectedNode
Dim Vals() As String = e.Form.Controls("TextBox1").text.split("\")
For i As Integer = Vals.Length -1 To 0 Step - 1
nd.text = vals(i)
nd = nd.ParentNode
If nd Is Nothing Then
Exit For
End If
Next
Tables("商品").Current.Save()
Split在编程基础讲述的,参考:
http://help.foxtable.com/topics/1421.htm
http://help.foxtable.com/topics/0245.htm
谢谢,可以了.但它的各级父节点不需要修改啊,所以我把你的代码改成为样了:
Dim tr As WinForm.TreeView = Forms("定位树").Controls("TreeView1")
Dim nd As WinForm.TreeNode = tr.SelectedNode
Dim Vals() As String = e.Form.Controls("TextBox1").text.split("\")
nd.text = vals(Vals.Length -1)
Tables("商品").Current.Save()
另外,如果我改的不是最低层的节点,而是中间层的,就出现表中节点不对的问题:
南京\鼓楼1
南京\鼓楼\汉口路1
南京\鼓楼\上海路
南京\鼓楼\新节点
写个代码判断,只要vals.length等于node的level,就说明用户没有乱改。