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.

有帮助吗?

解决方案

You can do this by doing a couple of things:

  • Set the TDBGrid.TitleFont.Orientation to 900, which is 90 degrees.

  • Use an interposer class to change the TDBGrid first (column header) row height. The interposer class gives you access to the RowHeights property of the grid, which isn't published in TDBGrid:

    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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top