获取TreeView CheckBox所有选中的节点值。@H_404_1@
见图:@H_404_1@
代码:以后肯定会用到的。@H_404_1@
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Me.TreeView1.ExpandAll() End Sub Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click Dim s As String Me.TextBox1.Clear() For Each node As TreeNode In Me.TreeView1.Nodes s = getNodeText(node) If String.IsNullOrEmpty(s) = False Then Me.TextBox1.Text &= s End If Next End Sub Function getNodeText(ByVal pNode As TreeNode) As String Dim s As String = String.Empty If pNode.Checked Then s &= pNode.Text & System.Environment.NewLine If pNode.Nodes.Count > 0 Then For Each node As TreeNode In pNode.Nodes s &= getNodeText(node) Next End If Return s End Function End Class @H_404_1@