开发者

How to set the appearance of a cell in a DevExpress grid?

开发者 https://www.devze.com 2023-01-12 06:04 出处:网络
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!

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, b开发者_JAVA百科ut the other 99 will still be executing code to determine whether their appearance needs altering!

There has to be another way - but what?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号