如何在表单初始化中填充树视图。 [英] How to populate a tree view in form initialization.

查看:85
本文介绍了如何在表单初始化中填充树视图。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试以下面的格式显示树视图,数据将从外部源填充。请您分享您的想法我们如何可以在初始化表单时将数据绑定到节点。



Hi Guys,

I am trying to display a tree view in below format and data will be populated from external source.Could you please share your ideas how we can bind the data to nodes while initialing the form itself.

+---Name1
      |
      +------Name1
      |         |
      |         +-----Name1
      |         |        |
      |         |        +-----Name1
      |         |        |
      |         |        +-----Name2
      |	        |        |
      |	        |        +-----Name3
      |         |                |
      |         |                +-----Name1
      |	        |                |
      |	        |                +-----Name2
      |         |
      |         +-----Name2
      |	        |
      |	        +-----Name3
      |
      +------Name2
      |         |
      |         +-----Name1
      |         |
      |         +-----Name2
      |	        |
      |	        +-----Name3
      |    
      +------Name3
      |         |
      |         +-----Name1
      |         |
      |         +-----Name2
      |	        |
      |	        +-----Name3
      |
      +------Name4
                |
                +-----Name1
                |
                +-----Name2
      	        |
      	        +-----Name3



代码:


Code :

public List ScriptCmnd(string s)
        {

            si.StartInfo.Arguments = s;
            si.Start();
            string output = si.StandardOutput.ReadToEnd();
            List result = output.Split(''\n'').ToList();
            si.Close();
            return result;
        }

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if ( e.Node.Level != 0)
            {
                string removeStr = "Project.pj";
                List result = ScriptCmnd("/c si viewproject --no --fields=name --project=''" + e.Node.Name);
                result.RemoveAll(x => x == "" || !(x.Contains("project.pj")));
                if (result.Count != 0)
                {
                    foreach (string sr in result)
                    {
                        TreeNode trChild = new TreeNode();
                        trChild.Text = sr;
                        trChild.Name = e.Node.Name.Remove(e.Node.Name.IndexOf(removeStr, StringComparison.OrdinalIgnoreCase), removeStr.Length) + sr;
                        
                        treeView1.SelectedNode.Nodes.Add(trChild);
                        treeView1.SelectedNode.ExpandAll();
                    }
                }
            }
        }

推荐答案

ASP.NET中的TreeView控件 [ ^ ]

ASP.NET TreeView Control&客户端的浏览器 [ ^ ]

ASP.NET 2.0 TreeView控件 [ ^ ]

从ASP.Net中的数据库绑定Treeview [ ^ ]

使用数据库的Treeview操作 [ ^ ]

如何在分层次序中使用TreeView绑定多个SQL Server表 [ ^ ]

将TreeView控件绑定到XML数据 [ ^ ]



这些文章可能对您有所帮助。

快乐编码
TreeView Control in ASP.NET[^]
ASP.NET TreeView Control & the Client''s Browser[^]
The ASP.NET 2.0 TreeView Control[^]
Bind Treeview from a DataBase in ASP.Net[^]
Treeview Operations Using Database[^]
How to Bind Multiple SQL Server Tables With a TreeView in a Hierarchical Order[^]
Binding The TreeView Control to XML Data[^]

these article may help you.
Happy coding


这篇关于如何在表单初始化中填充树视图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆