folgende Events sind fuer den anfang interessant
der code gehoert zum sourcecode von oben ich hoffe du kommst damit klar:
1. Anzeigen Text
Delphi-Quellcode:
procedure TFormChildArchiv.vstGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: Integer; TextType: TVSTTextType;
var CellText: WideString);
var
Data: PTreeData;
begin
Data := Sender.GetNodeData(Node);
if data.FObject <> nil then
begin
case Column of
0:
begin
if Node.Parent = Sender.RootNode then
celltext := TTreeDataClass(Data.FObject).FTestStr1
else
celltext := TTreeDataClass(Data.FObject).FTestStr1
end;
1:
if Node.Parent = Sender.RootNode then
celltext := ''
else
celltext := DateTostr(TTreeDataClass(Data.FObject).FDokDatum);
2:
if Node.Parent = Sender.RootNode then
celltext := ''
else
celltext := TTreeDataClass(Data.FObject).MASUCH;
3:
if Node.Parent = Sender.RootNode then
celltext := ''
else
celltext := TTreeDataClass(Data.FObject).FUserInitial;
4:
if Node.Parent = Sender.RootNode then
celltext := ''
else
celltext := TTreeDataClass(Data.FObject).FDOKNR;
end;
end;
end;
2. bildchen anzeigen
Delphi-Quellcode:
procedure TFormChildArchiv.vstGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: Integer;
var Ghosted: Boolean; var ImageIndex: Integer);
var
Data: PTreeData;
begin
Data := Sender.GetNodeData(Node);
case Kind of
ikNormal, ikSelected:
if (Column = 0) and (Node.Parent = Sender.RootNode) then
ImageIndex := TTreeDataClass(Data.FObject).Icon;
ikState:
case Column of
0:
if Node.Parent <> Sender.RootNode then
ImageIndex := 5;
end;
end;
end;
3. sortieren der spalten
Delphi-Quellcode:
procedure TFormChildArchiv.vstHeaderClick(Sender: TVTHeader;
Column: Integer; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
if Button = mbLeft then
begin
with Sender, Treeview do
begin
if SortColumn > NoColumn then
Columns[SortColumn].Options := Columns[SortColumn].Options + [coParentColor];
// Do not sort the last column, it contains nothing to sort.
if Column = 0 then
SortColumn := NoColumn
else
begin
if (SortColumn = NoColumn) or (SortColumn <> Column) then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending;
Columns[SortColumn].Color := $F7F7F7;
SortTree(SortColumn, SortDirection, False);
end;
end;
end;
end;
procedure TFormChildArchiv.vstCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: Integer; var Result: Integer);
var
Data1, Data2: PTreeData;
begin
Data1 := Sender.GetNodeData(Node1);
Data2 := Sender.GetNodeData(Node2);
case Column of
0:
Result := CompareText(TtreeDataClass(Data1.FObject).TestStr1,
TtreeDataClass(Data2.FObject).TestStr1);
1:
Result := Trunc(TTreeDataClass(Data1.FObject).DokDatum -
TTreeDataClass(Data2.FObject).DokDatum);
2:
Result := CompareText(TTreeDataClass(Data1.FObject).MASUCH,
TTreeDataClass(Data2.FObject).MASUCH);
3:
Result := CompareText(TTreeDataClass(Data1.FObject).UserInitial,
TTreeDataClass(Data2.FObject).UserInitial);
4:
Result := StrToInt(TTreeDataClass(Data1.FObject).DOKNR) -
StrToInt(TTreeDataClass(Data2.FObject).DOKNR);
end;
end;
4. Freigeben der Nodes
Delphi-Quellcode:
procedure TFormChildArchiv.vstFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PTreeData;
begin
Data := VST.GetNodeData(Node);
if not Assigned(Data) then
exit;
Data.FObject.Free;
end;
Hoffe du kommst damit zurecht