Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: Get the edit mode of VirtualStringTree after first click

I would like to edit a cell (node) from the VirtualStringTree directly after I click on the cell (something like a StringGrid with the options goEditing:True and goAlwaysShowEditor:True)

I've setup the option of toEditable:True, toEditOnClick:True and editDelay:0 but VirtualStringTree component it goes to edit mode after the second click (first is focusing the cell and secondly is editing)

like image 419
REALSOFO Avatar asked Sep 18 '25 20:09

REALSOFO


2 Answers

I don't think there's a way to configure what you want, however you can use e.g. the OnFocusChanged event and invoke the edit mode manually with a code like this:

procedure TForm1.VirtualStringTree1FocusChanged(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex);
begin
  Sender.EditNode(Node, Column);
end;

The problem of the above workaround is that the edit mode is invoked even if you select different node by keyboard, which may not be exactly what you want.

like image 113
TLama Avatar answered Sep 20 '25 11:09

TLama


Get the event OnEditing and set the Allowed flag to true.

Procedure TForm1.vtListEditing(Sender: TBaseVirtualTree; Node: PVirtualNode;
  Column: TColumnIndex; var Allowed: Boolean);
begin
  Allowed := true;
end;
like image 43
user173399 Avatar answered Sep 20 '25 10:09

user173399