DevExpress主细节行单元格样式

时间:2017-07-07 13:05:18

标签: c# gridview devexpress master-detail

我想根据一些条件更改gridview的主细节行样式。我的代码是这样的;

        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;
                    }
                }

            }
        };

我的父行和详细信息行具有相同的列,它必须类似于详细信息行&#39;列值与父行的列值不同,单元格颜色将为红色。

1 个答案:

答案 0 :(得分: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