I have tried but could not make my program to Check/Uncheck and virtual tree node. Below is my code
In short, I want to check the node when mouse click anywhere on it.
Can someone please help.
unit Unit2;
interface
////////////////////////////////
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvTreeViewBase, AdvTreeViewData,
AdvCustomTreeView, AdvTreeView;
type
TForm2 = class(TForm)
TV1: TAdvTreeView;
procedure FormActivate(Sender: TObject);
procedure TV1GetNumberOfNodes(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; var ANumberOfNodes: Integer);
procedure TV1GetNodeText(Sender: TObject; ANode: TAdvTreeViewVirtualNode;
AColumn: Integer; AMode: TAdvTreeViewNodeTextMode; var AText: string);
procedure TV1GetNodeCheckType(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; AColumn: Integer;
var ACheckType: TAdvTreeViewNodeCheckType);
procedure TV1NodeClick(Sender: TObject; ANode: TAdvTreeViewVirtualNode);
procedure TV1BeforeCheckNode(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; AColumn: Integer; var ACanCheck: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormActivate(Sender: TObject);
begin
TV1.BeginUpdate;
tv1.ClearNodes;
tv1.ClearColumns;
tv1.Columns.Add.Text := 'Col1';
tv1.EndUpdate;
end;
procedure TForm2.TV1BeforeCheckNode(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; AColumn: Integer; var ACanCheck: Boolean);
begin
ACanCheck := True;
end;
procedure TForm2.TV1GetNodeCheckType(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; AColumn: Integer;
var ACheckType: TAdvTreeViewNodeCheckType);
begin
ACheckType := tvntCheckBox;
end;
procedure TForm2.TV1GetNodeText(Sender: TObject; ANode: TAdvTreeViewVirtualNode;
AColumn: Integer; AMode: TAdvTreeViewNodeTextMode; var AText: string);
begin
if AMode = tntmDrawing then
AText := 'Node ' + IntToStr( ANode.Index );
end;
procedure TForm2.TV1GetNumberOfNodes(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; var ANumberOfNodes: Integer);
begin
if ANode.Level = -1 then
ANumberOfNodes := 8;
end;
procedure TForm2.TV1NodeClick(Sender: TObject; ANode: TAdvTreeViewVirtualNode);
begin
tv1.CheckVirtualNode( ANode, 0 );
end;
end.
////////////////////////////////////////////////