偶数行的外观是否会覆盖某些行的自定义外观?

发布于 2024-08-06 07:25:46 字数 285 浏览 8 评论 0原文

让我们弄清楚这里的情况。 让我们以 WIN 形式创建一个 devexpress 的 gridview 控件。让我们将网格偶数行的外观设置为背景颜色= color.whiteSmoke(据说是为了帮助用户轻松区分行)。我们在设计时这样做。 现在,让我们以编程方式将一些与我在事件中的条件相匹配的行设置为红色:gridView_RowStyle。

问题是,符合我的条件的偶数行仍然是白烟色?!?!?

这是否意味着偶数行的外观被覆盖为自定义外观???

我不明白。 我应该做什么才能使符合我的条件的行显示为红色?

Let's clear the situation in here.
Let's have a devexpress's gridview control in a WIN form. Let's set the Appearance of the Even rows of the grid have the backcolor = color.whiteSmoke (say to help the users distiguish the rows easily). We do this in design time.
Now, let's do programmatically color in red some rows that match my condition in an event: gridView_RowStyle.

The problem is than the even rows, matching my condition are still colored in whitesmoke?!?!?

Does that mean that the appearance of the even rows are overwritten to the custom appearance???

I'm not getting that.
What I'm I supposed to do so that the rows that match my condition are colored in red?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

完美的未来在梦里 2024-08-13 07:25:46

嗯,很明显,是的,偶数行的外观被覆盖为我在 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});

这确实解决了我的问题。希望它对某人有帮助。

Well, as it was obvious, yes, the appearance of the even rows was overwritten to the appearance of the rows I colored at the RowStyle event.

The solution, so that the overwritten is avoided is the use of the DevExpress.XtraGrid.StyleFormatCondition object, while programmatically binding the grid, as in the following example:

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

This did solve my problem. Hope it helps somebody.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文