2012-06-20 45 views
1

我正在使用實體框架和DevExpress 10.5 XtraGrid。 假設我們有實體 entity實體框架的兩級深度主細節

所以我的觀點是使用XtraGrids和主詳細信息表格中顯示它們。 gridControl的水平樹應該是這樣的: enter image description here

爲MainGrid所以我已經實現了這樣的活動

#region gridView1_enents 
    private void gridView1_MasterRowEmpty(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowEmptyEventArgs e) 
    { 
     districts c = (districts)gridView1.GetRow(e.RowHandle); 
     e.IsEmpty = c.districtparts.Count == 0; 
    } 

    private void gridView1_MasterRowGetRelationCount(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationCountEventArgs e) 
    { 
     e.RelationCount = 1; 
    } 

    private void gridView1_MasterRowGetRelationName(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationNameEventArgs e) 
    { 
     e.RelationName = "districtparts"; 
    } 

    private void gridView1_MasterRowGetChildList(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetChildListEventArgs e) 
    { 
     districts c = (districts)gridView1.GetRow(e.RowHandle); 
     e.ChildList = new BindingSource(c, "districtparts"); 
    } 
    #endregion 

和工作正常:有一個網格,顯示我區,我可以擴大每行和那裏顯示另一個與分區網格 問題是:我該怎麼做才能顯示votecallers。目標是具有兩個級別的主從細節層次結構。這意味着地區應該有地區部分,地區部分應該有投票者。

謝謝。

回答

2

實測值的溶液here

而一些不相關的話,以滿足30個字符的要求=)