unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Contnrs, StdCtrls, VirtualTrees, VSTBindObjectListUnit;
type
TNodeDataClass =
class
private
FSpalte1:
string;
FSpalte2:
string;
FSpalte3: Integer;
public
property Spalte1:
string read FSpalte1
write FSpalte1;
property Spalte2:
string read FSpalte2
write FSpalte2;
property Spalte3: Integer
read FSpalte3
write FSpalte3;
end;
TForm1 =
class(TForm)
vst: TVirtualStringTree;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure vstGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
private
{ Private-Deklarationen }
DataList: TObjectList;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
TBindVSTToObjectListHelperClass.BindVST(VST,DataList);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
NodeData: TNodeDataClass;
begin
DataList := TObjectList.Create;
for i := 0
to 3
do
begin
NodeData := TNodeDataClass.Create;
NodeData.Spalte1 := IntToStr(i);
NodeData.Spalte2 := '
Spalte '+IntToStr(i);
NodeData.Spalte3 := i;
DataList.Add(NodeData);
end;
end;
procedure TForm1.vstGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var
data: PTreeData;
begin
data:= Sender.GetNodeData(Node);
if not Assigned(data^.FObject)
then Exit;
case Column
of
0: CellText := TNodeDataClass(data^.FObject).FSpalte1;
1: CellText := TNodeDataClass(data^.FObject).FSpalte2;
2: CellText := IntToStr(TNodeDataClass(data^.FObject).FSpalte3);
end;
end;
end.