TreeList结构及数据绑定


实体类

public class TreeListTest
{
public int ID { get; set; }

public int PARENTID { get; set; }

public string NAME { get; set; }
}

实例化数据

List<TreeListTest> list = new List<TreeListTest>();

list.Add(new TreeListTest {
ID=1,
PARENTID=1,
NAME="宝马"
});
list.Add(new TreeListTest
{
ID = 2,
PARENTID = 1,
NAME = "宝马x5"
});

list.Add(new TreeListTest
{
ID = 3,
PARENTID = 3,
NAME = "奔驰"
});

list.Add(new TreeListTest
{
ID = 4,
PARENTID = 3,
NAME = "奔驰c200"
});

this.treeList1.DataSource = list;
this.treeList1.KeyFieldName = "ID";
this.treeList1.ParentFieldName = "PARENTID";
this.treeList1.Columns[0].Caption = "测试";

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM