AddChildObjectFirst (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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

Code

#include <memory>       // For STL auto_ptr class
Graphics::TBitmap *MyBitMap;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  static std::auto_ptr<Graphics::TBitmap> _MyBitMapCleaner((MyBitMap = new Graphics::TBitmap()));  // Just create it once.
  MyBitMap->LoadFromFile("..\\littleB.bmp");
  TreeView1->Items->BeginUpdate(); // Keep the node from painting until it is built.
  TreeView1->Items->AddChildObjectFirst(
	TreeView1->Selected, L"New ઝદ૪ Item", MyBitMap);
  TreeView1->Items->EndUpdate();
}

Uses

Personal tools
Assistance