DevExpress TreeListLookupEdit常用技巧


//設定為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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM