Shaul Behr
Shaul Behr

Reputation: 38003

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

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?

Upvotes: 2

Views: 4680

Answers (2)

DevExpress Team
DevExpress Team

Reputation: 11376

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.

Upvotes: 3

Bernard
Bernard

Reputation: 7961

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.

Upvotes: 1

Related Questions