delphivirtualtreeview

How can I adjust the indentation of a Virtual TreeView column when auto resizing?


I want to make my columns in a VirtualStringTree to have the same indentation on the left and on the right side of the content when auto sizing a column.

Take a look at my sample VST with Header Option hoDblClickResize turned on.

VST sample image

In this picture I doubleclicked the column header to auto resize the "Time" column. I highlighted the difference in indentation between the left and the right side of the column.

How can I adjust the VST so the right indent becomes the same size as the left indent? Do I have to hack the VST source code? If so, can anybody point me to the right place in the code?


Solution

  • Write the OnAfterGetMaxColumnWidth event handler and increase the MaxWidth parameter there. I haven't found a property doing this.

    procedure VirtualStringTreeAfterGetMaxColumnWidth(Sender: TVTHeader; 
      Column: TColumnIndex; var MaxWidth: Integer);
    begin
      MaxWidth := MaxWidth + VirtualStringTree.TextMargin;
    end;