开发者

Multiple Selection Tree View Control for ASP.Net Web Application using C#.Net

开发者 https://www.devze.com 2023-03-30 05:08 出处:网络
Would like to know about the TREE VIEW CONTROL which would allow me to select multiple nodes and those selected no开发者_StackOverflowdes can then be dragged and dropped onto the other drive.Is there

Would like to know about the TREE VIEW CONTROL which would allow me to select multiple nodes and those selected no开发者_StackOverflowdes can then be dragged and dropped onto the other drive.Is there any Property available for multiple selection or how exactly we can go about doing it.. Thank You


You could use the checked property on the treeview and allow multiple selections based on the state of the checkbox on each node.

You could iterate through the treenodes to see which were checked (you'd really use recursion but here is an example that would iterate through two layers of nodes):

StringBuilder sb = new StringBuilder(); 

foreach (TreeNode t in treeView1.Nodes)
{
     if (t.Checked == true) sb.Append(t.Text + Environment.NewLine);

     if (t.Nodes.Count > 0)
     {
          foreach (TreeNode tt in t.Nodes)
          {
               if (tt.Checked == true)
                    sb.Append(tt.Text + Environment.NewLine);
          }
    }
}

MessageBox.Show(sb.ToString(), "Checked Nodes")
0

精彩评论

暂无评论...
验证码 换一张
取 消