RAD Studio VCL Reference
|
Removes a node from the tree view.
procedure Delete(Node: TTreeNode);
__fastcall Delete(TTreeNode Node);
Delete removes the tree node specified by the Node parameter and all its children from the tree view.
C++ Examples:
/* The following example deletes an item in the tree view when the user clicks on it, and if the checkbox is checked. This example requires a populated TreeView. */ void __fastcall TForm1::TVMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { THitTests HT; if (CheckBox1->Checked && Sender->ClassNameIs("TTreeView")) { TTreeView *pTV = dynamic_cast<TTreeView *>(Sender); HT = pTV->GetHitTestInfoAt(X,Y); if (HT.Contains(htOnItem)) pTV->Items->Delete(pTV->GetNodeAt(X,Y)); } }
Delphi Examples:
{ The following example deletes an item in the tree view when the user clicks on it, and if the checkbox is checked. This example requires a populated TreeView. } procedure TForm1.TVMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var HT : THitTests; begin if (CheckBox1.Checked) and (Sender is TTreeView) then begin with Sender as TTreeView do begin HT := GetHitTestInfoAt(X,Y); if (htOnItem in HT) then Items.Delete(GetNodeAt(X,Y)); end; end; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|