右鍵“工具箱”選擇“選擇項” 彈出對話框 選擇“瀏覽” 選中下載還的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