unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TTreeNodeEx =
class(TTreeNode)
private
_Beschreibung:
String;
protected
public
published
property Beschreibung:
String read _Beschreibung
write _Beschreibung;
end;
TForm1 =
class(TForm)
Button1: TButton;
TreeView1: TTreeView;
StatusBar1: TStatusBar;
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
procedure FormCreate(Sender: TObject);
procedure TreeView1CreateNodeClass(Sender: TCustomTreeView;
var NodeClass: TTreeNodeClass);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.TreeView1CreateNodeClass(Sender: TCustomTreeView;
var NodeClass: TTreeNodeClass);
begin
NodeClass := TTreeNodeEx;
end;
procedure TForm1.FormCreate(Sender: TObject);
var lvTreeNodeEx: TTreeNodeEx;
begin
lvTreeNodeEx := Self.TreeView1.Items.AddFirst(
nil, '
Test 1')
as TTreeNodeEx;
lvTreeNodeEx.Beschreibung := '
Beschreibung 1';
lvTreeNodeEx := Self.TreeView1.Items.AddFirst(
nil, '
Test 2')
as TTreeNodeEx;
lvTreeNodeEx.Beschreibung := '
Beschreibung 2';
lvTreeNodeEx := Self.TreeView1.Items.AddFirst(
nil, '
Test 3')
as TTreeNodeEx;
lvTreeNodeEx.Beschreibung := '
Beschreibung 3';
lvTreeNodeEx := Self.TreeView1.Items.AddFirst(
nil, '
Test 4')
as TTreeNodeEx;
lvTreeNodeEx.Beschreibung := '
Beschreibung 4';
lvTreeNodeEx := Self.TreeView1.Items.AddFirst(
nil, '
Test 5')
as TTreeNodeEx;
lvTreeNodeEx.Beschreibung := '
Beschreibung 5';
end;
procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
if Self.TreeView1.Selected <>
nil
then StatusBar1.SimpleText := (Self.TreeView1.Selected
as TTreeNodeEx).Beschreibung
else StatusBar1.SimpleText :='
';
end;
end.