DevExpress TreeListLookupEdit常用技巧
2017-05-26 12:04
295 查看
//设定为CheckBox可用
this.treeListLookUpEdit1.Properties.TreeList.OptionsView.ShowCheckBoxes = true;
//设定默认显示值
this.treeListLookUpEdit1.EditValue = "请选择";
//获取CheckBox选中项的
List<TreeListNode> aa=treeListLookUpEdit1TreeList.GetAllCheckedNodes();
//数据绑定(3种方法,不推荐直接绑定List<T>类型)
方法1:DataTable
//设置父子递归关系字段
this.treeListLookUpEdit1.Properties.TreeList.KeyFieldName = "DepartmentID";
this.treeListLookUpEdit1.Properties.TreeList.ParentFieldName = "ParentID";
//设置绑定字段和显示字段
this.treeListLookUpEdit1.Properties.ValueMember = "DepartmentID";
this.treeListLookUpEdit1.Properties.DisplayMember = "DepartmentName";
//绑定数据源
this.treeListLookUpEdit1.Properties.DataSource = dtSource;
★说明 如果不需要获取节点值的情况下可以绑定DataTable,List<T>,BindingList<T> 三种数据源
其中后两种可以通过构造函数进行简单转换。区别在于数据源绑定BindingList的时候可以方便的获取节点值(该问题TreeList,GridControl同样存在)
List<DepartmentInfo> lstDepartment=new List<DepartmentInfo>();
BindingList<DepartmentInfo> aa=new BindingList<DepartmentInfo>(lstDepartment);
获取节点值方法(对应上述绑定的泛型方法):
DepartmentInfo tt = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DepartmentInfo; //数据源绑定BindingList<DepartmentInfo>
DataRowView drv = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DataRowView; //数据源绑定DataTable
this.treeListLookUpEdit1.Properties.TreeList.OptionsView.ShowCheckBoxes = true;
//设定默认显示值
this.treeListLookUpEdit1.EditValue = "请选择";
//获取CheckBox选中项的
List<TreeListNode> aa=treeListLookUpEdit1TreeList.GetAllCheckedNodes();
//数据绑定(3种方法,不推荐直接绑定List<T>类型)
方法1:DataTable
//设置父子递归关系字段
this.treeListLookUpEdit1.Properties.TreeList.KeyFieldName = "DepartmentID";
this.treeListLookUpEdit1.Properties.TreeList.ParentFieldName = "ParentID";
//设置绑定字段和显示字段
this.treeListLookUpEdit1.Properties.ValueMember = "DepartmentID";
this.treeListLookUpEdit1.Properties.DisplayMember = "DepartmentName";
//绑定数据源
this.treeListLookUpEdit1.Properties.DataSource = dtSource;
★说明 如果不需要获取节点值的情况下可以绑定DataTable,List<T>,BindingList<T> 三种数据源
其中后两种可以通过构造函数进行简单转换。区别在于数据源绑定BindingList的时候可以方便的获取节点值(该问题TreeList,GridControl同样存在)
List<DepartmentInfo> lstDepartment=new List<DepartmentInfo>();
BindingList<DepartmentInfo> aa=new BindingList<DepartmentInfo>(lstDepartment);
获取节点值方法(对应上述绑定的泛型方法):
DepartmentInfo tt = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DepartmentInfo; //数据源绑定BindingList<DepartmentInfo>
DataRowView drv = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DataRowView; //数据源绑定DataTable
相关文章推荐
- [DevExpress]TreeListLookUpEdit带checkbox之经典运用
- [DevExpress]TreeListLookUpEdit带checkbox之经典运用
- DevExpress Report 其他常用设计技巧
- C# Devexpress TreeListLookUpEdit控件默认选择一个数据
- [导入]Oracle 常用技巧和脚本
- Unix平台下的常用命令技巧之二 TCP/IP网络配置
- 常用ASP。NET技巧
- 46种网页常用技巧(javascript)
- Unix平台下的常用命令技巧之一 tar包、压缩与解压缩
- VC常用技巧集锦(一)
- Oracle 常用技巧和脚本 选择自 yanlixin4csdn 的 Blog
- Java数据库编程中的几个常用技巧
- Java数据库编程中的几个常用技巧
- Java数据库编程中的几个常用技巧
- 网页常用技巧
- 网页 的 40大 常用技巧
- 常用的查看数据库的SQL Oracle经验技巧集
- vc常用技巧
- Html常用技巧
- Java数据库编程中的几个常用技巧