unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Virtualtrees;
type
TmyData =
class
public
var Value:
String;
end;
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
myVST: TVirtualStringTree;
procedure myVSTGettext(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType;
var CellText: WideString);
procedure myVSTNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
NewText: WideString);
procedure myVSTEdited(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var tmp: TmyData;
begin
myVST := TVirtualStringTree.Create(Self);
myVST.Parent := Self;
myVST.Width := Self.ClientWidth;
myVST.Height := Self.ClientHeight;
myVST.OnGetText := myVSTGettext;
myVST.OnNewText := myVSTNewText;
myVST.OnEdited := myVSTEdited;
myVST.TreeOptions.MiscOptions := myVST.TreeOptions.MiscOptions+ [toEditable];
myVST.TreeOptions.SelectionOptions := myVST.TreeOptions.SelectionOptions + [toMultiSelect];
myVST.NodeDataSize := SizeOf(TmyData);
tmp := TmyData.Create;
tmp.Value := '
test';
myVST.AddChild(
nil, tmp);
myVST.Anchors := [akLeft,akTop,akRight,akBottom];
end;
procedure TForm1.myVSTEdited(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex);
begin
ShowMessage('
test');
end;
procedure TForm1.myVSTGettext(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
begin
Celltext := TmyData(Sender.GetNodeData(Node)^).Value
end;
procedure TForm1.myVSTNewText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; NewText: WideString);
begin
TmyData(Sender.GetNodeData(Node)^).Value := NewText;
end;
end.