Print Page | Close Window

Columnstroke in TAdvTreeView

Printed From: TMS Software
Category: VCL Components
Forum Name: VCL General
Forum Discription:
URL: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=13431
Printed Date: 21 Nov 2019 at 3:38am


Topic: Columnstroke in TAdvTreeView
Posted By: Ronald Janse
Subject: Columnstroke in TAdvTreeView
Date Posted: 17 May 2019 at 10:58am
I want to devide the columns in my TAdvTreeView with a vertical line of 1 pixel in diameter. This seems to be not possible.
The only way to get a vertical line is to set NodesAppearance ColumnStroke Width to 1. But then the columns get a line of 1 around them on all sides, resulting in a vertical line with a width of 2 between the columns. The headers do have a vertical line of 1...



Replies:
Posted By: Bruno Fierens
Date Posted: 18 May 2019 at 9:01am
You're correct. We will fix this.


Posted By: Pieter Scheldeman
Date Posted: 20 May 2019 at 10:34am
Hi,

We'll look into improving/fixing the behaviour, but you can also workaround it by drawing a line instead of a rectangle with the following code:

procedure TForm1.AdvTreeView1AfterDrawColumn(Sender: TObject; ACanvas: TCanvas;
  ARect: TRectF; AColumn: Integer);
begin
  ACanvas.MoveTo(Round(ARect.Right), Round(ARect.Top));
  ACanvas.LineTo(Round(ARect.Right), Round(ARect.Bottom));
end;

procedure TForm1.AdvTreeView1BeforeDrawColumn(Sender: TObject;
  ACanvas: TCanvas; ARect: TRectF; AColumn: Integer; var AAllow,
  ADefaultDraw: Boolean);
begin
  ADefaultDraw := False;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvTreeView1.ColumnStroke.Style := psSolid;
  AdvTreeView1.ColumnStroke.Color := clRed;
end;


Posted By: Ronald Janse
Date Posted: 20 May 2019 at 1:14pm
This workaround does not work when the GetNodecolor event is used, as I do. I use it to get colored rows like this:
procedure TFormEenKolomTree.TVGetNodeColor(Sender: TObject; ANode: TAdvTreeViewVirtualNode; var AColor: TColor);
begin
  if (ANode.Children = 0) then
  begin
    if (ANode.Index mod 2) = 0 then AColor := clWhite
    else AColor := $00F4F4F4;
  end;
end;



Posted By: Pieter Scheldeman
Date Posted: 20 May 2019 at 1:47pm
The column stroke is always painted under the nodes, therefore, filling the nodes will override the line drawing. We have added this on our todolist for further investigation.



Print Page | Close Window