I would like to know how to show the column title in dbgrid delphi vertical. At this stage the title headings is a bit long and i want to display them vertical. I am using delphi 2010 and there is nothing in the object inspector to set any allignment settings for vertical or 90 degrees. Any help will be appreciated.
1 Answers
1
votes
You can do this by doing a couple of things:
Set the
TDBGrid.TitleFont.Orientationto900, which is 90 degrees.Use an interposer class to change the
TDBGridfirst (column header) row height. The interposer class gives you access to theRowHeightsproperty of the grid, which isn't published inTDBGrid:
implementation
type
THackGrid=class(TDBGrid);
procedure TForm1.FormCreate(Sender: TObject);
begin
THackGrid(DBGrid1).RowHeights[0] := 300;
end;
Calculating the proper height to use for RowHeights[0] is an exercise left to you. :-) As @TLama said in his comment, you're better off owner-drawing the grid to get the proper fit and alignment of the text; how to do so would be another question (but there are examples that exist already for doing so, so make sure you look at them first before asking it).
Font.Orientationproperty which, if you set to 900 (which equals to 90°) will render the font vertically. The problem is how to increase the height of the header or how to re-position the rendered caption, the best would be still to have a owner draw event for this. - TLamaColumn, expand theTitle, expand theFont. You can also set it for the entireDBGridusing theTitleFontproperties. - Ken White