1. : TreeView1 ImageList1. ImageList1 .
2. (Button):
1. 1 Name AddButton.
2. 2 Name AddChildButton.
3. 3 Name DelButton.
4. 4 Name EditButton.
, 26.
26 -.
3. Images .
4. . :
procedure TForm1.AddButtonClick(Sender: TObject);
var
CaptionStr:String;
NewNode:TTreeNode;
begin
CaptionStr:= ' ';
if not InputQuery (' ', ' ', CaptionStr) then exit;
NewNode:= TreeView1.Items.Add(TreeView1.Selected, CaptionStr);
if NewNode.Parent<>nil then NewNode.ImageIndex:=1;
end;
5. :
var
CaptionStr:String; NewNode:TTreeNode; begin
CaptionStr:=' ';
if not InputQuery(' ', ' ',CaptionStr) then exit;
NewNode:=TreeView1.Items.AddChild(TreeView1.Selected, CaptionStr);
if NewNode.Parent<>nil then NewNode.ImageIndex:=1;
, . , AddChild. Add , . , - AddChild, . Add .
6. :
if TreeView1.Selected<>nil then TreeView1.Items.Delete(TreeView1.Selected);
7. :
procedure TTreeViewForm.EditButtonClick(Sender: TObject);
var
CaptionStr:String;
begin
CaptionStr:='';
if not InputQuery(' ', ' ',CaptionStr) then exit;
TreeView1.Selected.Text:=CaptionStr;
end;
8. . OnClose :
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
TreeView1.SaveToFile(ExtractFilePath(Application.ExeName)+'tree.dat');
end;
.
9. . OnShow :
Procedure Form1.FormShow(Sender: TObject);
begin
if FileExists(ExtractFilePath(Application.ExeName)+'tree.dat') then TreeView1.LoadFromFile(ExtractFilePath(Application.ExeName)+'tree.dat');
end;
27-
10. . 27 .
3.