3

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)

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
REALSOFO
  • 852
  • 9
  • 37

2 Answers2

3

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.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • 1
    You're welcome! But that keyboard focus change is quite annoying there. It doesn't look well if you press e.g. page down key and you move by page down and the node there starts to be edited. – TLama Jan 02 '14 at 11:31
0

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;
user173399
  • 464
  • 5
  • 21
  • Why would you do this ? – TLama Oct 05 '14 at 16:20
  • This is the recommended way of starting editing of a node text on a click, just like in Windows explorer. It won't cause the problem that you mention above from keyboard navigation. – user173399 Oct 06 '14 at 01:28