How to show virtual tree grid lines for nodes that do not yet exist?

I am using SoftGem VirtualStringTree in Delphi 7.

Is there a way to enable full grids (like in TListView)? I can only find toShowHorzGridLinesthat shows only the rows for the current nodes, and not something in the empty space below, and toShowVertGridLineswhere only the vertical lines are shown.

How to show them in empty space before adding items?

+5
source share
1 answer

I don’t think there is an easy way to implement this without changing the method PaintTree, since none of the node events can be fired because the nodes whose lines are to be drawn simply do not exist yet.

, node. DefaultNodeHeight , :

enter image description here

:

type
  TVirtualStringTree = class(VirtualTrees.TVirtualStringTree)
  public
    procedure PaintTree(TargetCanvas: TCanvas; Window: TRect; Target: TPoint;
      PaintOptions: TVTInternalPaintOptions; PixelFormat: TPixelFormat = pfDevice); override;
  end;

implementation

{ TVirtualStringTree }

procedure TVirtualStringTree.PaintTree(TargetCanvas: TCanvas; Window: TRect;
  Target: TPoint; PaintOptions: TVTInternalPaintOptions;
  PixelFormat: TPixelFormat);
var
  I: Integer;
  EmptyRect: TRect;
  PaintInfo: TVTPaintInfo;
begin
  inherited;
  if (poGridLines in PaintOptions) and (toShowHorzGridLines in TreeOptions.PaintOptions) and
    (GetLastVisible <> nil) then
  begin
    EmptyRect := GetDisplayRect(GetLastVisible,
      Header.Columns[Header.Columns.GetLastVisibleColumn].Index, False);
    EmptyRect := Rect(ClientRect.Left, EmptyRect.Bottom + DefaultNodeHeight,
      EmptyRect.Right, ClientRect.Bottom);
    ZeroMemory(@PaintInfo, SizeOf(PaintInfo));
    PaintInfo.Canvas := TargetCanvas;
    for I := 0 to ((EmptyRect.Bottom - EmptyRect.Top) div DefaultNodeHeight) do
    begin
      PaintInfo.Canvas.Font.Color := Colors.GridLineColor;
      DrawDottedHLine(PaintInfo, EmptyRect.Left, EmptyRect.Right,
        EmptyRect.Top + (I * DefaultNodeHeight));
    end;
  end;
end;

node height:

enter image description here

(, ), , . LineStyle lsSolid, .

+5

All Articles