TTreeNodesDelete (Delphi)
Description
The following example deletes an item in the tree view when you click it, and if the check box is checked. This example requires a populated TreeView.
Code
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;
Uses
- Vcl.ComCtrls.TCustomTreeView.Items ( fr | de | ja )
- Vcl.ComCtrls.TTreeNodes.Delete ( fr | de | ja )