轉帖|使用教程|編輯:龔雪|2017-01-25 11:28:17.000|閱讀 852 次
概述:DevExpress GridControl使用技巧及代碼示例
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數據庫:C_ProductPlan ,C_ProductPlanItem
DTO定義:(實現每個計劃條目-Master,對應多個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是對應的子集合序號(可以有多個子集合),IsEmpty=true時主列表前面的"+"灰色
getCount 返回最大的子集合數
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.添加一個level1 將level1重命名稱ProcessConfig(對應上面IRelationList.GetRelationName的返回
3.level1 添加 gridview2 ,需要手動設置gridview的列,可以設置gridview2的ViewCaption
4.獲取數據后將items轉化成producePlanItems,并綁定到UI(轉載:博客園-遺忘海岸)
想要了解更多DevExpress使用技巧?海量視頻課程以及最專業的DevExpress培訓盡在。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn