We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Changing backcolor in a single row depending on a condition

Hello: I''m new using GridDataBoundGrid and I would like to change the style of a single row using the PrepareViewStyleInfo event, but depending on the cell value of another column. I have enabled dragging columns to reorder them, so how can I get the value of that specific column by his name? And one more question, how can I extend the grid header backgroung until the right side without extending the header of the last column?

3 Replies

AD Administrator Syncfusion Team November 9, 2004 03:05 PM UTC

To get the colIndex from a column name, try: int colIndex = this.grid.Binder.NameToColIndex("SomeName"); If I understand your question about coloring only the header to the right of the visible grid, then I do not know of any grid properties that would help you here. If you want to color the whole area, try setting grid.Properties.BackgroundColor. Another thing to try would be to set grid.HScrollPixel = true to see if this will hide the problem (with this setting you should not see any space to the right unless there are not enough columns to fill the clentwidth in the first place.) If you want try to put up a fake header, you could put up a panel the height of the header row, and try to dock it so it will stick at the top of the grid. This would likely take some trial and error.


JE Jose Egea November 10, 2004 09:23 AM UTC

First question solved. Thanks. As you say I would like to put up a fake header, and it can be a good idea to dock a panel at the top of the grid. But how can I give it the same appearance as a header with ThemesEnabled? Can you help me about that, please?


AD Administrator Syncfusion Team November 10, 2004 10:47 AM UTC

At worst you could dock a second grid into the panel with no rows and a single column there. Then all you would see would be a true grid header which should used the themed drawing. This may be overkill, but it would likely work.

Loader.
Live Chat Icon For mobile
Up arrow icon