Grid HorzAlignment stops working after applying FNC Style at runtime

Using Delphi 10.4 Sydney Enterprise edition with Webcore 1.4.2.0 and FNC UI Pack 3.1.0.0., Chrome Version 83.0.4103.116 (Official Build) (64-bit)

Loading an FNC Style at runtime via a call to TMSFNCStylesManager1.LoadStyleFromText(StyleText) causes the Grid.Columns[index].HorzAlignment property to be ignored. All text defaults to gtaLeading.

The property appears to work correctly if the style is set at design time.

Hi,

To properly apply the style, UseColumns is set to False. If you have any column related settings, then these will be ignored. You can set UseColumns back to True after loading the style. Alternatively use a BeginUpdate & EndUpdate after setting the HorzAlignment property.

Hello Pieter,

Setting UseColumns to true again after loading the style does correct the alignment issue. Unfortunately though it then causes the grid's cell text color to change. For instance, for the Dark style the font color changes from white to black. Wrapping both the property change and the style loading with BeginUpdate/EndUpdate has no effect on the outcome. Please note that the text color change might not be apparent until the cells are redrawn.

Thank you for you assistance.

To combine styling with horizontal text alignment you can keep the original code (UseColumns := False) and then set the alignment in the OnGetCellLayout event.

Pieter,

The OnGetCellLayout event approach worked.

Thank You!

1 Like