Posted 9 February 2022, 1:39 pm EST
Hello Wolfgang,
As per the developers, this was originally designed that way: when applying a theme, the style properties are reset to their default values (based on the current VisualStyle), regardless of whether they were set by the user or not. And we cannot change this behavior at the moment, without a complete reworking of all styles that we can’t afford at the moment.
The workaround indicated in the description is the correct solution. This approach is best used in cases where the number of columns and fixed rows may change.
In addition, you can also use custom styles, as well as column properties (TextAlign, ImageAlign) using this logic: custom styles override build-in styles, column properties override custom styles.
This can be done both at design time and at run-time (in code). The implementation of this sample, in this case, will look like this:
// once during FlexGrid initialization
// create custom style with the right properties
var style = c1FlexGrid1.Styles.Add("CustomCellStyle");
style.WordWrap = true;
style.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
// set custom style for all columns except fixed (works with themes)
// the custom style will be merged with the built-in style,
// but WordWrap and TextAlign property will be overrided by the custom style.
for (int i = c1FlexGrid1.Cols.Fixed; i < c1FlexGrid1.Cols.Count; i++)
c1FlexGrid1.Cols[i].Style = style;
// set TextAlign for fixed columns,
// this value will be used regardless of styles and theme
for (int i= 0; i < c1FlexGrid1.Cols.Fixed; i++)
c1FlexGrid1.Cols[i].TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.LeftTop;
// set TextAlign for fixed rows,
// this value will be used regardless of styles and theme
for (int i = 0; i < c1FlexGrid1.Rows.Fixed; i++)
c1FlexGrid1.Rows[i].TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.LeftTop;
the same can be done at design time using Column and Styles editor forms. This approach is best used in cases where the number of columns and fixed rows is constant.
Regards,
Prabhat Sharma.