EditText (Delphi)
From RAD Studio Code Examples
Language:
Description
This example is an event handler for a pop-up menu item. The handler enables the editing of the current item in a TListView control. The example would also work with a TTreeView control, or with any instance of a control class derived from TCustomViewControl.
Code
procedure TForm1.EditItem1Click(Sender: TObject); begin TreeView1.Selected.EditText; end; procedure TForm1.FormCreate(Sender: TObject); var MyTreeNode1, MyTreeNode2: TTreeNode; begin with TreeView1.Items do begin Clear; { Remove any existing nodes. } MyTreeNode1 := Add(nil, 'RootTreeNode1'); { Add a root node. } { Add a child node to the node just added. } AddChild(MyTreeNode1,'ChildNode1'); {Add another root node.} MyTreeNode2 := Add(MyTreeNode1, 'RootTreeNode2'); {Give MyTreeNode2 to a child... } AddChild(MyTreeNode2,'ChildNode2'); {Change MyTreeNode2 to ChildNode2 } { ... and add a child node to it.} MyTreeNode2 := TreeView1.Items[3]; AddChild(MyTreeNode2,'ChildNode2a'); {Add another child to ChildNode2, after ChildNode2a. } AddChild(MyTreeNode2,'ChildNode2b'); {Add another root node.} Add(MyTreeNode1, 'RootTreeNode3'); end; end; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin PopupMenu1.Popup(Left + X, Top + Y); end;
Uses
- Vcl.ComCtrls.TTreeNode.EditText ( fr | de | ja )
- Vcl.ComCtrls.TCustomTreeView.Selected ( fr | de | ja )