DevExpress TreeListLookupEdit常用技巧
//設(shè)定為CheckBox可用 ???????????
this.treeListLookUpEdit1.Properties.TreeList.OptionsView.ShowCheckBoxes = true;
//設(shè)定默認(rèn)顯示值 ???????????
this.treeListLookUpEdit1.EditValue = "請(qǐng)選擇";
?
//獲取CheckBox選中項(xiàng)的
List<TreeListNode> aa=treeListLookUpEdit1TreeList.GetAllCheckedNodes();
?
//數(shù)據(jù)綁定(3種方法,不推薦直接綁定List<T>類(lèi)型)
方法1:DataTable
//設(shè)置父子遞歸關(guān)系字段 ???????????
this.treeListLookUpEdit1.Properties.TreeList.KeyFieldName = "DepartmentID"; ???????????
this.treeListLookUpEdit1.Properties.TreeList.ParentFieldName = "ParentID";
//設(shè)置綁定字段和顯示字段 ???????????
this.treeListLookUpEdit1.Properties.ValueMember = "DepartmentID"; ???????????
this.treeListLookUpEdit1.Properties.DisplayMember = "DepartmentName";
//綁定數(shù)據(jù)源 ???????????
this.treeListLookUpEdit1.Properties.DataSource = dtSource;
★說(shuō)明? 如果不需要獲取節(jié)點(diǎn)值的情況下可以綁定DataTable,List<T>,BindingList<T> 三種數(shù)據(jù)源
其中后兩種可以通過(guò)構(gòu)造函數(shù)進(jìn)行簡(jiǎn)單轉(zhuǎn)換。區(qū)別在于數(shù)據(jù)源綁定BindingList的時(shí)候可以方便的獲取節(jié)點(diǎn)值(該問(wèn)題TreeList,GridControl同樣存在)
List<DepartmentInfo> lstDepartment=new List<DepartmentInfo>();
BindingList<DepartmentInfo> aa=new BindingList<DepartmentInfo>(lstDepartment);
?
獲取節(jié)點(diǎn)值方法(對(duì)應(yīng)上述綁定的泛型方法):
DepartmentInfo tt = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DepartmentInfo; //數(shù)據(jù)源綁定BindingList<DepartmentInfo>
DataRowView drv = this.treeListLookUpEdit1TreeList.GetDataRecordByNode(tln) as DataRowView; //數(shù)據(jù)源綁定DataTable
?
posted on 2017-05-26 12:04 飄揚(yáng)De黑夜 閱讀(...) 評(píng)論(...) 編輯 收藏轉(zhuǎn)載于:https://www.cnblogs.com/volts0302/p/6907869.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的DevExpress TreeListLookupEdit常用技巧的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 数据库的硬迁移和mysql 5.5.38
- 下一篇: 求助,后台跳转至前台,如何实现,谢谢