2013-01-23 11 views
0

我是使用DevExpress工具的新手。 我設計了一個GridControl,它有一個主GridView和另外三個GridView。 我打開了主GridView的功能:EnableMasterViewMode = True,EnableDetailToolTip = true。如何設計DevExpress「Detail Tabs」並填充它?

我想設計這樣的事情在提出: http://demos.devexpress.com/ASPxGridViewDemos/MasterDetail/DetailTabs.aspx

所以:

  1. 我的設計只是目前的第一級,當我運行該項目,我怎麼能得到的觀點嵌套的網格出現在上一個鏈接?

  2. 我將在網格中綁定的數據在運行時存儲在列表中,而不是存儲在數據庫中,那麼如何從該列表而不是數據庫填充網格單元格和列?

回答

1

Source:

如果您正在使用的WinForms然後請查看以下幫助主題:Binding Controls to Data Created at RuntimeHow to: Bind a Control to Data Created at Runtime

GridControl會自動處理將集合作爲主 - 關係關係返回的屬性。 因此,您只應在您的類中實現相應的屬性,併爲您的GridControl.DataSource屬性分配一個主集合,就像您爲標準的.Net DataGridView控件一樣。這個任務不是特定於我們的XtraGrid。 也請嘗試與XtraGrid一起提供的GridTutorials項目的GridUnboundMasterView模塊。

網格僅爲在其根級別創建實現IList接口的屬性的詳細視圖。在GridControl - Detail views are now created if a detail collection type is an interface type inherited from IList票證中描述了此行爲。推薦的方法是與IList一起實施IList界面。在這種情況下,網格將自動創建詳細視圖,如Implement Master-Detail Relationships for Objects via Collection Properties幫助主題中所述。您還可以通過描述here所述的事件提供主 - 細節關係。

示例代碼片段:

gridControl1.DataSource = new NestedRecords(); 
//... 
public class NestedRecords : ArrayList { 
    public NestedRecords() { 
     Add(new NestedRecord("Customers", new ChildRecordsCustomers())); 
     Add(new NestedRecord("Products", new ChildRecordsProducts())); 
     Add(new NestedRecord("Shippers", new ChildRecordsShippers())); 
    } 
    public virtual new NestedRecord this[int index] { 
     get { return (NestedRecord)(base[index]); } 
    } 
} 

參考:
Master detail with IList property
Using master detail with iList
How to create the master-details gridcontrol with Ilist
How does XtraGrid detects a Collection for Master-Detail grids

如果您使用的WebForms那麼請查看以下文檔幫助主題:Master-Detail Relationship,並嘗試實行收集離子數據源而不是數據表。

相關問題