简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM