I want to define the following custom styles :
-SelectedRow : style to apply on the currently selected row
-SelectedCell : style to apply to the currently selected cell
-Alternating : style to apply to the alternating "block" of rows (ex: make "blocks" of rows by changing the background colors, like in some spreadsheet)
The Alternating style would be applied to the RowStyle in the GridControl.OnQueryCellInfo method as each qualifing row becomes visible.
The SelectedRow and SelectedCell style would be applied on the Row style and cell style respectively in the GridControl.OnCurrentCellActivating method.
first of all, i'm having trouble creating GridInfoStyle objects because there are no public constructors and the static GridInfoSTyle.Empty seems to always return the same Instance.
Second, i've tried to use the GridInfoStyle.ModifyStyle method with mixed results (eratic behavior ending a big red X apprearing in the GridControl). I've also tried setting the styles as BaseStyles using GridControl.BaseStyleMap["..."] which seems to create a BaseStyle object when the specified key is not in the collection.
To summarise, i need to be able to somehow merge a custom style with the row or cell style and be able to revert back to the original style once the row/cell is deactivated.
Does anyone know how i could do this?
Olivier
AD
Administrator
Syncfusion Team
April 29, 2003 08:02 PM UTC
You can create a style with code like:
GridStyleInfo selectedRowStyle = new GridStyleInfo();
selectedRowStyle.BackColor = Color.LightBlue;
The first comment is that all the style's you want to set could be done in QueryCellInfo or PrepareViewStyleInfo just like you mentioned that the alternating colors would be set.
OC
Olivier Choquette
April 30, 2003 10:24 AM UTC
Ok, i can create the GridStyleInfo object (i don't know what's the version of my documentation, but there is no documented constructor for that object).
When i modify the RowStyle of the currently selected cell in the OnQueryCellInfo, the changes don't seem to be refreshed immediately (have to minimise and maximise the window for example).
Olivier
AD
Administrator
Syncfusion Team
April 30, 2003 12:59 PM UTC
> When i modify the RowStyle of the currently selected cell in the OnQueryCellInfo, the changes don't seem to be refreshed immediately (have to minimise and maximise the window for example).
>
Try also setting grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow
This will force the grid to repaint the complete row when you move the current cell from one row to another. If you continue you to have problems, just attach a small sample project and we can check what you might do wrong.
Stefan
OC
Olivier Choquette
April 30, 2003 04:21 PM UTC
Setting the RefreshCurrentCellBehavior solved the refresh problem and i moved all the style modification stuff in the PreprareViewStyleInfo and it seems to work.
thanks!
Olivier