Winform 快速初始化Dev TreeList树控件的数据


设计要求:表结构必须是树节点结构。
使用Id,ParentId数据结构即可初始化TreeList,如下图:
图中TreeList控件命名tlCategory。
产品类别数据表定义:

实现代码:
最后,需要说明TreeList.Columns的配置:
在TreeList控件上点右键,选择Run Designer菜单,打开Property Editor窗体,Add一个Column, 设置FieldName为CategoryName用于显示数据。然后设置Caption,搞定。


扫一扫加微信

产品类别数据表定义:
实现代码:
C# Code:
tlCategory.KeyFieldName = "CategoryId";//设置主键
tlCategory.ParentFieldName = "ParentId";//设置父级主键
tlCategory.RootValue = "";//顶级树结点的值
tlCategory.DataSource = _BllInstance.GetProductCategory();//绑定产品类别(树)的数据源
//来源:C/S框架网(www.csframework.com) QQ:1980854898
tlCategory.KeyFieldName = "CategoryId";//设置主键
tlCategory.ParentFieldName = "ParentId";//设置父级主键
tlCategory.RootValue = "";//顶级树结点的值
tlCategory.DataSource = _BllInstance.GetProductCategory();//绑定产品类别(树)的数据源
//来源:C/S框架网(www.csframework.com) QQ:1980854898
最后,需要说明TreeList.Columns的配置:
在TreeList控件上点右键,选择Run Designer菜单,打开Property Editor窗体,Add一个Column, 设置FieldName为CategoryName用于显示数据。然后设置Caption,搞定。

扫一扫加微信


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网