好吧,很明显,是的,偶数行的外观被我在 RowStyle 事件中着色的行的外观所覆盖。
避免覆盖的解决方案是使用 DevExpress.XtraGrid.StyleFormatCondition 对象,同时以编程方式绑定网格,如下例所示:
this.gridControl.DataSource = dataTable;
DevExpress.XtraGrid.StyleFormatCondition styleFormatCondition1 =
new DevExpress.XtraGrid.StyleFormatCondition();
styleFormatCondition1.Appearance.BackColor = System.Drawing.Color.LightCoral;
styleFormatCondition1.Appearance.BackColor2 = System.Drawing.Color.SeaShell;
styleFormatCondition1.Appearance.Options.UseBackColor = true;
styleFormatCondition1.ApplyToRow = true;
styleFormatCondition1.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal;
styleFormatCondition1.Column = this.gridView.Columns["MY_COLUMN"];
styleFormatCondition1.Value1 = "0";
this.gridView.FormatConditions.AddRange(
new DevExpress.XtraGrid.StyleFormatCondition[] {styleFormatCondition1});
这确实解决了我的问题。希望它可以帮助某人。