TAdvStringGrid: Text alignment in cell

Hello!


I want to align the text in the first line vertical = vtaCenter. 

I do so:

procedure TForm2.AdvStringGrid1GetAlignment(Sender: TObject; ARow,
  ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
if ARow = 0 then
  begin
    VAlign := vtaCenter;
end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  AdvStringGrid1.RowHeights [0] := 50;
  AdvStringGrid1.Cells[0, 0] := '22';
end;

As a result of this code, there is no alignment = vtaCenter.

How can I make the text alignment vertical vtaCenter?

Version of TAdvStringGrid  = 6.2.7.1

To enable vertically centered alignment, make sure to set grid.WordWrap to false.


Thank you very much, it worked! But where is the logic?

Vertical alignment and wordwrap are mutually exclusive. This is due to a limitation in the Microsoft Windows text drawing API that does not allow to have wordwrapped text with other vertical alignment than top alignment.

Ок, thanks a lot!

I know this is an old thread... What if you want word wrapping enabled - i.e. you have more than line of text displayed in your grid cell - and you also want centered vertical alignment?