• C# windform 使用TreeGridView


    1 下载 treeGridView.DLL库文件。
    2 添加到工程中。

    右键“工具箱”选择“选择项” 弹出对话框

    选择“浏览” 选中下载还的dll库文件。完成后工具箱中会有 treeGridView控件,如下图

     拖动控件到windform 中

    添加代码

     List<personcl> lst = new List<personcl>();
                    //personcl per = new personcl { name = "cese", age = 1 };
                    personcl per1 = new personcl { name = "cese", age = 2 };
                    //lst.Add(per);
                    lst.Add(per1);
                    personcl per2 = new personcl { name = "cese", age = 3 };
                    per1.subitem.Add(per2);
                    personcl per3 = new personcl { name = "cese", age = 4 };
                    per2.subitem.Add(per3);
                    //lst.Add(new personcl { name = "wyl", age = 10, subitem = new List<personcl> { new personcl { name = "wyl", age = 11 } } });
    
                    SetNodes(lst, treeGridView1.Nodes);
    
    public class personcl
        {
            public string name = "1";
            public int age = 10;
    
            public List<personcl> subitem = new List<personcl>();
        }
    

      

    private void SetNodes(IEnumerable<personcl> lst, TreeGridNodeCollection nodes)
            {
               
                foreach (var item in lst)
                {
                    var node = nodes.Add(item.name, item.age);
                    node.ImageIndex = 0;
                    SetNodes(item.subitem, node.Nodes);
                }
            }
    

      

     

    参考: https://www.cnblogs.com/mrtiny/p/5174095.html

  • 相关阅读:
    详解Codis安装与部署
    停车场地图开发
    dlib换脸
    海康相机官网硬触发设置
    python操作数据库
    心率和血氧测量
    音乐模块
    flask网页显示图片
    树莓派识别二维码
    树莓派python获取自身IP
  • 原文地址:https://www.cnblogs.com/wangyonglai/p/10406965.html
Copyright © 2020-2023  润新知