如何设置 DevExpress 网格中单元格的外观?

发布于 2024-09-15 12:11:16 字数 355 浏览 3 评论 0原文

我在我的项目中使用 DevExpress XtraGrid 。我需要设置特定单元格的外观(特别是背景颜色)。我在网格中找不到任何执行此操作的属性或方法!我能看到执行此操作的唯一方法是捕获 GridView 的 RowCellStyle 事件,并确定给定单元格是否需要更改其外观 - 这是效率极低,因为可能 100 个单元格中有 1 个需要更改其外观,但其他 99 个单元格仍将执行代码以确定其外观是否需要更改!

一定有别的办法——但是什么办法呢?

I am using a DevExpress XtraGrid in my project. I need to set the appearance of a specific cell (specifically, the background color). And I cannot find any property or method in the grid that does this! The only way I can see of doing this is by catching the RowCellStyle event of the GridView, and determining whether the given cell needs to have its appearance altered - which is grossly inefficient, since maybe 1 out of 100 cells will need its appearance altered, but the other 99 will still be executing code to determine whether their appearance needs altering!

There has to be another way - but what?

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

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

发布评论

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

评论(2

南…巷孤猫 2024-09-22 12:11:16

您已经找到了实现此任务的绝对正确的方法 - 处理 RowCellStyle 事件并更改 e.Appearance 属性。我还可以看出,此事件不会经常引发,并且仅针对当前在屏幕上可见的单元格引发。因此,我确信您不会注意到此事件处理程序代码导致的速度减慢。如果您看到此内容,请在支持中心发布一个显示性能问题的示例项目 (http://devexpress.com /Support/Center/),我们会找到改进它的方法。

You have found an absolutely correct way of implementing this task - handle the RowCellStyle event and change the e.Appearance property. I can also tell that this event is not raised very often and it is only raised for cells which are currently visible on the screen. So, I am sure, you will not notice a slowdown caused by this event handler's code. If you see this, post a sample project showing the performance issue in the support center (http://devexpress.com/Support/Center/) and we will find a way to improve it.

寂寞陪衬 2024-09-22 12:11:16

这就是我必须这样做的方式。您可能需要检查DevExpress 论坛,如果只是为了看看较新版本的 XtraGrid 控件是否支持这是一个更好的方式。

That's the way I've had to do it. You might want to check the DevExpress Forums, if only to see whether a newer version of the XtraGrid control does this in a better way.

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