TAdvStringGrid... vertical text alignment...

Hello,

Delphi 10.2.3, grid version 8.6.1.0

What is the VAlignment property function? It is not in the developers guide.
It appears the VAlignment property has no affect on text vertical placement in the cells. Perhaps I am in error.

And I see the VAlignment for cell properties.

How do I set the grid to default all cell text to vertical center alignment unless I change it via the cell properties?

I know of the OnGetCellAlignment event. The cell vertical alignment needs to be saved with the grid stream. Not sure how using the event will accomplish saving the property.

Cheers,

Mark

I found with wordwrap false, all text is aligned to bottom, regardless of VAlignment settinng. Wordwarp true, all texts aligns to top.

When I found that the default vertical alignment was not centre, I used the OnGetAlignment event on each grid to set it to centre. Slightly annoying as you'd think that centre should be the default.

Right, I can do that but, does the alignment save when the grid is saved to stream?

Not sure what I am doing wrong.

Using the CellProperties[c,r].VAlignment property has zero change in the vertical alignment.
Word false and multilinecells is false.

  1. When WordWrap = true, text is always top aligned (behavior of the underlying Windows API DrawText() used internally.
  2. When WordWrap = false, global vertical text alignment is set with grid.VAlignment
  3. When you want to override vertical alignment per cell, implement OnGetAlignment and set vertical alignment via the VAlign parameter of this event

Thanks for the response.

https://en.delphipraxis.net/applications/core/interface/file/attachment.php?id=4494

And is the text alignment saved/restored when save/load from stream?

  1. We have no plans to change this as a change requires 2x DrawText() calls. One for text size measurement and a second one to do effective drawing. This will halve the drawing performance.
  2. Event driven settings are not persisted in stream

Thanks for the response.
For #1 not sure an issue, IMHO. No one is running on a 386.

Looks like I am left with one option, go with owner drawing.

No one uses a 386 but it is the multiplicator. This needs to be multiplied by the number of simultaneously visible cells. Many users count on the fast drawing that exists now.

Sure but without testing it is only speculation of a significant impact on drawing speed that can be detected.

I created the v1.0 of TAdvStringGrid in 1996 and worked on it for 25 years so far and I have even more years of experience with Windows APIs. I think I know what I'm talking about and I'm not willing to sacrifice anything at the very core of drawing performance in the grid. Too many users are used to it and I'm not going to take it away from them. Please accept this as my final answer.

I did not ask for nor seek a sacrifice from anyone.
An option, property, to enable/disable text drawing in cells using the selected alignment options would be nice. Just an opinion.
I have moved on and started testing with owner drawing.
Please accept this as my final comment

If anyone is interested, attached is a sample project for owner drawing with text alignment.
grid1.zip (56.3 KB)

Thanks for the grid.VAlignment prompt. I don't know how I missed that!

You are welcome.

This is great! Just what I needed. Multiple lines in a few cells, need wrapping = true and centered vertical alignment. Worked like a charm - thank you! Passing on your zip file and my implementation of your fine work to my cohorts...

You are welcome.