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

Override columnstyle with rowstyle in GDBG?

I''m trying to set a rowstyle that should "override" the current style for all cells in the row. I have some columnstyles defined, but I would like the rowstyle to take precendence over this. All cells that doesn''t have any style set through its columnstyle get the new backcolor but the others keep their columnstyle color. I use this code in my QueryCellInfo event: if(e.ColIndex == -1 && e.RowIndex == somerowindex) { e.Style.ReadOnly = true; e.Style.BackColor = Color.LightGray; }

4 Replies

AD Administrator Syncfusion Team November 9, 2005 11:26 AM UTC

Hi Tomas, Once you have set a style.ReadOnly = true;, you must then set grid.IgnoreReadOnly to be able to change it. Please try this sample.It seems to be working fine. RowStyleOverrideColStyle.zip Please refer this sample for more details: C:\program files\syncfusion\essential studio\3.3.0.0\Windows\Grid.Windows\samples\Quick Start\GridStyleInfoAtWork Let us know if this helps. Best Regards, Jeba.


TO Tomas November 9, 2005 11:49 AM UTC

Thank you Jeba. It seems that there is a difference between setting the columsstyle using: grid.Binder.InternalColumns[3].StyleInfo.BackColor and the way you did when it worked: grid.Model.ColStyles[3].BackColor How come there is a difference and is your way prefered always?


AD Administrator Syncfusion Team November 9, 2005 01:28 PM UTC

Setting the column style using Model.ColStyles will make the column style ''obey'' the style precedences shown in the GridStyleInfoAtWork. These precedences work on the Model level (or GridControl) level. But GridDataBoundGrid adds an extra style level (GridBoundColumn.StyleInfo object for each column) for columns which takes precedence over the Model level Colstyles/RowStyles. So, setting GridBoundColumn.StyleInfo overrides the properties that were set using ColStyles. In general, if you want to try to use the fact that RowStyles take precedence over column styles in a GridDataBoundGrid, then you would want to avoid using GridBoundColumn.StyleInfo to set style properties and use Model.ColStyles instead. But it is this GridBoundColumn.StyleInfo property that you have access to through the GriddataBoundGrid designer. So, if you are setting such properties as design time and want to have a property take precedence over the GridBoundColumn.StyleInfo set property, then in QueryCellInfo, instead of checking e.ColIndex == -1, you could check e.Colindex > 0. This would effectively set the cell style for the grid cell, and this will ovrride the setting from GridBoundColumn.StyleInfo.


TO Tomas November 10, 2005 10:37 AM UTC

Thanks Clay, it all makes sense now.

Loader.
Live Chat Icon For mobile
Up arrow icon