DevExpress 主详细信息行单元格样式

DevExpress master detail row cell style

我想根据某些条件更改我的 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;
                    }
                }

            }
        };

我的父行和明细行有相同的列,如果明细行的列值与父行的列值不同,单元格颜色将为红色。

发件人:How To Dynamically Format Columns For A Detail View

Columns are already created, when the MasterRowExpanded event occurs. Please try to use this event to customize them as you require, and let me know whether this solution meets your needs.

参考这些 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