函数
private void GetSelectedTreeNode(TreeNodeCollection nodes, ListselectedNodes) { foreach (TreeNode node in nodes) { if (node.Checked) { selectedNodes.Add(node); } GetSelectedTreeNode(node.Nodes, selectedNodes); } }
ListselectedNodes=new List (); GetSelectedTreeNode(treeView1.Nodes, selectedNodes); foreach (TreeNode node in selectedNodes) { a += node.Name + ","; } MessageBox.Show(a.Trim(','));