RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNodes.EndUpdate Method

Re-enables screen repainting and node reindexing that was turned off with the BeginUpdate method.

Pascal
procedure EndUpdate;
C++
__fastcall EndUpdate();

Use the EndUpdate method to enable screen updating after BeginUpdate has been called. Calls to BeginUpdate are cumulative, so calling EndUpdate will only update the tree view if every other call to BeginUpdate has already been matched by a call to EndUpdate.  

C++ Examples: 

 

/*
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.
*/
#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's built
  TreeView1->Items->AddChildObjectFirst(
    TreeView1->Selected, "New Item", MyBitMap);
  TreeView1->Items->EndUpdate();
}

 

Delphi Examples: 

{
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.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  MyBitMap : TBitmap;
  node : TTreeNode;
begin
  MyBitMap := TBitmap.Create;
  MyBitMap.LoadFromFile('littleB.bmp');
  TreeView1.Items.BeginUpdate;
  node:= TreeView1.Items.AddChildObjectFirst(
    TreeView1.Selected, 'New Item', MyBitMap);
//  node.ImageIndex:= -1;
  TreeView1.Items.EndUpdate;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!