以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何用目录树的节点形成组合框的列表值?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=22809)

--  作者:zpx_2012
--  发布时间:2012/8/24 13:02:00
--  如何用目录树的节点形成组合框的列表值?

各位老师,想在目录树中用节点得到组合框的列表值,用了以下代码:

 

Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox1")
\'选取节点进行排序
Dim nms As New List(of String)
For Each nd As WinForm.treenode In tr1.nodes
    nms.add(nd.name)
Next
nms.sort()
cb.ComboList = "nms"

 

但点击组合框时下面什么值都没有?请问是哪里不正确?

谢谢!


--  作者:狐狸爸爸
--  发布时间:2012/8/24 14:50:00
--  
Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox1")
\'选取节点进行排序
Dim nms As New List(of String)
For Each nd As WinForm.treenode In tr1.nodes
    nms.add(nd.name)
Next
nms.sort()
cb.ComboList = String.Join("|", nms.Toarray)

--  作者:kylin
--  发布时间:2012/8/24 14:51:00
--  
For Each nd As WinForm.treenode In tr1.nodes
  nms = nms  + "|" + nd.name
Next

--  作者:zpx_2012
--  发布时间:2012/8/24 15:46:00
--  
谢谢!狐爸的那个是可以了,kylin老师的那个是遍历后那最后那一句cb.ComboList = ?要怎么写才可以呢?
--  作者:狐狸爸爸
--  发布时间:2012/8/24 15:56:00
--  

Dim nms As String

Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox1")

For Each nd As WinForm.treenode In tr1.nodes
    nms = nms + "|" + nd.name
Next

cb.ComboList = nms