RAD Studio Athens

1.626

Description

The following example adds a new child to the selected item๏ฟฝs list of child items in the tree view control. The new item is identified by the text ๏ฟฝNew Item๏ฟฝ. The TBitmap object is attached to the new item.

Code

procedure TForm1.Button1Click(Sender: TObject);
var MyBitMap : TBitmap;
begin
  MyBitMap := TBitmap.Create;
  MyBitMap.LoadFromFile('littleB16.bmp');
  TreeView1.Items.BeginUpdate;  // Keep the node from painting until it is built.
  TreeView1.Items.AddChildObject(
    TreeView1.Selected, 'New Item', MyBitMap);
  TreeView1.Items.EndUpdate;
end;

Uses