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

trying to learn

In the grid sample for GridInfoStyleAtWork there is the following method for applying the user defined base style. private void ApplyBaseCheck(GridStyleInfo style, CheckBox check, ColorPickerButton _color) { _color.BackColor = _color.SelectedColor; GridStyleInfo style1 = new GridStyleInfo(); if(check.Checked) { style.BackColor = _color.SelectedColor; style1.BaseStyle = "BackColorTest"; gridControl1.ChangeCells(GridRangeInfo.Cells(2, 1, 4, 3), style1); } else { style1.ResetBaseStyle(); gridControl1.ChangeCells(GridRangeInfo.Cells(2, 1, 4, 3), style1); } } } Why don't you pass style to the line below instead of instancing a new GridStyleInfo? gridControl1.ChangeCells(GridRangeInfo.Cells(2, 1, 4, 3), style1);

2 Replies

AD Administrator Syncfusion Team July 1, 2003 05:17 PM

1) style.BackColor = _color.SelectedColor; 2) style1.BaseStyle = "BackColorTest"; 3) gridControl1.ChangeCells(GridRangeInfo.Cells(2, 1, 4, 3), style1); style is the basestyle.StyleInfo. Line (1) sets the backcolor of this basestyle. Line (2) sets the BaseStyle property of the new style1. And finally, in line (3) the ChangeCells says to make the BaseStyle property of the cells in the range to be BackColorTest. What this means is that, later, when you make a change to the BackColorTest basestyle, these cells will automatically reflect the change. If we do as you suggest, you are saying to apply the basestyle settings to the range. At first this would create the same display because the cell styles in the range would be modified to be the same as the basestyles. But we would not actually be setting the BaseStyle property of each cell in the range. This means, that if we later change the BackColorTest base style, the change will not be automatically reflected in the range of cells.


JR Joseph Rezuke July 1, 2003 06:36 PM

Thanks Clay, you're explanation is very clear. The point I was missing is that you have to set the BaseStyle property for the cells GridStyleInfo object.

Loader.
Live Chat Icon For mobile
Up arrow icon