2017-07-07 53 views
0

我想根據某些條件更改我的gridview主細節行樣式。我的代碼是這樣的;DevExpress主細節行單元格樣式

 GridView newDetailView = grdLog.CreateView("GridView") as GridView; 
     GridView View = sender as GridView; 
     gvLog.MasterRowGetLevelDefaultView += (s, e2) => 
     { 
      if (e.RowHandle >= 0) 
      { 
       for (int i = 0; i < gvLog.Columns.Count - 15; i++) 
       { 
        string strTimeKey1 = View.GetRowCellDisplayText(e.RowHandle, View.Columns[i]); 
        string strTimeKey2 = View.GetRowCellDisplayText(View.FocusedRowHandle, View.Columns[i]); 
        if (!strTimeKey1.Equals(strTimeKey2)) 
        { 
         e.Appearance.BackColor = Color.Red; 
        } 
       } 

      } 
     }; 

我父行和細節行具有相同的列,它必須像如果明細行」列的值是從父行的列值不同,單元格顏色會變成紅色。

回答

0

來源:How To Dynamically Format Columns For A Detail View

列已經創建,當MasterRowExpanded事件發生 。請嘗試使用此活動根據需要對其進行自定義, 並讓我知道此解決方案是否滿足您的需求。

參考這些DevExpress的主題:
Style conditions conditional formatting for master and detail views
How to set row style of Detail grid records after data binded to xtragrid master-detail data Master/Detail grid with StyleFormatCondition

+0

謝謝。我會嘗試他們。 @NiranjanKala – Mualla