I have a standard TStringGrid on a form.
I have one Fixed Row in the grid that contains a number of columns, which are all TGridColumns objects. I have set the column titles using the object inspector and the default orientation is horizontal. Is there any way you can make the orientation vertical (like you can in cells in Excel)?
I have a standard TStringGrid on a form. I have one Fixed Row in
Share
Here’s how to render the first row’s text vertically in Lazarus:
Here’s how to render the first row’s text of the
TStringGridvertically in Delphi:I would prefer to use the overriden
DrawCellprocedure because it seems to me as the easiest way to go because if you want to render the text simply in theOnDrawCellevent then you should consider:DefaultDrawingset toTruethen the text will already be rendered when theOnDrawCellevent is fired, so here I would recommend e.g. to store the cell captions in a separate variable, not intoCellsproperty so then no text will be rendered and you can draw your own stored captions verticallyDefaultDrawingset toFalsethen you’ll have to draw the whole cell by your own, including the 3D border, what is IMHO not so cool, and I would personally prefer to let the control draw the background for usHere is the Delphi code which uses the overriden
DrawCellprocedure. The text is being centered inside of the cell rectangle; please note that I haven’t used theDrawTextExfor text size measurement because this function doesn’t take the changed font orientation into account.And here’s how it looks like: