views:

75

answers:

2

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?

+1  A: 

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.

Bernard
+1  A: 

Hi,

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.

DevExpress Team
OK, I appreciate that you guys are monitoring SO for questions on your product! As it happens, I think the problem was caused by the fact that the previous programmer was using the grid not for its intended purpose, i.e. as a graphical overlay matrix on top of an image, with cell sizes of 5x5 pixels. That's basically showing 2 orders of magnitude more cells than a normal grid would, so I won't hold the performance issues against you! I've redone the whole design now using more appropriate tools... ;)
Shaul