C# windform 使用TreeGridView
程序员文章站
2022-11-18 08:06:32
右键“工具箱”选择“选择项” 弹出对话框 选择“浏览” 选中下载还的dll库文件。完成后工具箱中会有 treeGridView控件,如下图 拖动控件到windform 中 添加代码 参考: https://www.cnblogs.com/mrtiny/p/5174095.html ......
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
上一篇: 耐克眉,好看吗!
下一篇: 毛峰是绿茶吗?感觉是,感觉又不是