C#.WAB树控件问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 23:52:43
要求是循环树看看有没有被选中如果选择就把选中的子项相加逗号隔开.请哪位大虾指点指点希望有详细代码以供参考.

public string strCode = string.Empty;
private void GetNodeState(TreeNode tn)
{
foreach (TreeNode tnsub in tn.Nodes)
{
if (tnsub.Checked == true && tnsub.Tag!=null)
{
strCode += "'"+tnsub.Tag.ToString()+"',";
}
else
{
GetNodeState(tnsub);
}
}
}