1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
program treeviewtest;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,
SysUtils,
fpgfx,
gui_form,
gui_tree,
gfxbase;
type
TMainForm = class(TfpgForm)
private
tree: TfpgTreeView;
public
constructor Create(AOwner: TComponent); override;
end;
{ TMainForm }
constructor TMainForm.Create(AOwner: TComponent);
var
n: TfpgTreeNode;
i: integer;
s: string;
begin
inherited Create(AOwner);
WindowTitle := 'Treeview Test';
WindowPosition := wpUser;
SetPosition(100, 100, 300, 200);
tree := TfpgTreeView.Create(self);
tree.SetPosition(8, 8, Width-16, Height-16);
tree.Anchors := [anTop, anLeft, anRight, anBottom];
// tree.ShowColumns := True;
// tree.TreeLineStyle := lsSolid;
tree.ScrollWheelDelta := 30;
n := tree.RootNode.AppendText('Node 1');
n.AppendText('Node 1.1');
n.AppendText('Node 1.2');
n := tree.RootNode.AppendText('Node 2');
n.AppendText('Node 2.1');
n := n.AppendText('Node 2.2 The quick brownfox jumps over the...');
for i := 1 to 3 do
begin
s := Format('Node 2.2.%d', [i]);
n.AppendText(s);// + ' ' + s + ' ' + s);
end;
n.Parent.AppendText('Node 2.3');
tree.RootNode.FirstSubNode.Next.Collapse;
tree.RootNode.AppendText('Node 3');
tree.Selection := n;
end;
procedure MainProc;
var
frm: TMainForm;
begin
fpgApplication.Initialize;
frm := TMainForm.Create(nil);
frm.Show;
fpgApplication.Run;
end;
begin
MainProc;
end.
|