C# 偶数行的外观是否覆盖为某些行的自定义外观?
让我们把这里的情况弄清楚。 让我们在WIN窗体中使用DevXPress的gridview控件。让我们设置网格中的偶数行的外观,使其backcolor=color.whiteSmoke(比如说,帮助用户轻松区分这些行)。我们在设计阶段就这样做了。 现在,让我们以编程方式在事件:gridView_RowStyle中将一些符合我的条件的行涂成红色 问题是比偶数行,匹配我的条件仍然是白烟颜色 这是否意味着偶数行的外观将覆盖为自定义外观 我不明白。C# 偶数行的外观是否覆盖为某些行的自定义外观?,c#,devexpress,xtragrid,C#,Devexpress,Xtragrid,让我们把这里的情况弄清楚。 让我们在WIN窗体中使用DevXPress的gridview控件。让我们设置网格中的偶数行的外观,使其backcolor=color.whiteSmoke(比如说,帮助用户轻松区分这些行)。我们在设计阶段就这样做了。 现在,让我们以编程方式在事件:gridView_RowStyle中将一些符合我的条件的行涂成红色 问题是比偶数行,匹配我的条件仍然是白烟颜色 这是否意味着偶数行的外观将覆盖为自定义外观 我不明白。 我应该怎么做才能使符合我条件的行被涂成红色 很明显,是的
我应该怎么做才能使符合我条件的行被涂成红色 很明显,是的,偶数行的外观被覆盖为我在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});
这确实解决了我的问题。希望它对某人有所帮助。很明显,是的,偶数行的外观被覆盖为我在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});
这确实解决了我的问题。希望它能帮助别人