Hi, I would like to have a single pixel separator line between my columns (as per the column header if I set TopStroke.Width=1) If I define a colour for ColumnStroke, and leave the Width=1, I get a 2 pixel line (I assume because it's drawing the right side of the first column and the left side of the adjacent column) Is there currently a setting to do this?
Hi,
You can use the following code to achieve this, or draw a single pixel line between the columns with the OnBeforeDrawColumn and OnAfterDrawColumn events
var
I: Integer;
begin
AdvTreeView1.BeginUpdate;
for I := 0 to AdvTreeView1.Columns.Count - 1 do
begin
AdvTreeView1.Columns.UseDefaultAppearance := not Odd(I);
AdvTreeView1.Columns.Stroke.Color := clRed;
end;
AdvTreeView1.EndUpdate;
Alternative:
procedure TForm1.AdvTreeView1AfterDrawColumn(Sender: TObject;
ACanvas: TCanvas; ARect: TRectF; AColumn: Integer);
begin
if AColumn < AdvTreeView1.Columns.Count - 1 then
begin
ACanvas.MoveTo(Round(ARect.Right) - 1, Round(ARect.Top));
ACanvas.LineTo(Round(ARect.Right) - 1, Round(ARect.Bottom));
end;
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.Color := clRed;
end;
Kind Regards,
Pieter