轉(zhuǎn)帖|使用教程|編輯:龔雪|2017-01-25 11:28:17.000|閱讀 852 次
概述:DevExpress GridControl使用技巧及代碼示例
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數(shù)據(jù)庫:C_ProductPlan ,C_ProductPlanItem
DTO定義:(實(shí)現(xiàn)每個(gè)計(jì)劃條目-Master,對應(yīng)多個(gè)ProcessInfo-Detail)
[DataContract] [Serializable] public class PlanInfo:C_ProductPlan { public PlanInfo() { Items = new List<ProducePlanItem>(); } [DataMember] public List<ProducePlanItem> Items { get; set; } } [DataContract] [Serializable] public class ProducePlanItem :C_ProductPlanItem { public ProducePlanItem() { ProcessConfig = new List<ProcessInfo>(); } [DataMember] public List<ProcessInfo> ProcessConfig { get; set; } } [Serializable] public class ProcessInfo { public String Name{get;set;} public int Order{get;set;} public bool? IsChecked{get;set;} public String Memo{get;set;} }
UI定義:
index-是行記錄,relationIndex是對應(yīng)的子集合序號(hào)(可以有多個(gè)子集合),IsEmpty=true時(shí)主列表前面的"+"灰色
getCount 返回最大的子集合數(shù)
public class ProducePlanItems : ArrayList, IRelationList { public ProducePlanItems() { } #region IRelationList 成員 public System.Collections.IList GetDetailList(int index, int relationIndex) { return this[index].ProcessConfig; } public string GetRelationName(int index, int relationIndex) { return "ProcessConfig"; } public bool IsMasterRowEmpty(int index, int relationIndex) { return false; } public int RelationCount { get { return 1; } } #endregion public virtual new ProducePlanItem this[int index] { get { return base[index] as ProducePlanItem; } } }
需要引用Dexexpress.Data.dll,
1.gridview-MainView 綁定到UI中定義的ProducePlanItems.
2.添加一個(gè)level1 將level1重命名稱ProcessConfig(對應(yīng)上面IRelationList.GetRelationName的返回
3.level1 添加 gridview2 ,需要手動(dòng)設(shè)置gridview的列,可以設(shè)置gridview2的ViewCaption
4.獲取數(shù)據(jù)后將items轉(zhuǎn)化成producePlanItems,并綁定到UI(轉(zhuǎn)載:博客園-遺忘海岸)
想要了解更多DevExpress使用技巧?海量視頻課程以及最專業(yè)的DevExpress培訓(xùn)盡在。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn