How to move the selection in the treeview, akin to dbgrid.next/dbgrid.previous?
I'm trying to move the selection bar in the VST when down/up key is pressed in a TEdit control.
This I have tried, works, but seems too verbose to me for a simple task:
procedure TfrmUserManager.edtTaskFilterKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Node: PVirtualNode;
begin
if not Assigned(vstTasks.FocusedNode) then
Node:= vstTasks.GetFirst
else
Node:= vstTasks.FocusedNode;
if key = VK_DOWN then
vstTasks.FocusedNode:= vstTasks.GetNextVisible(Node)
else if key = VK_UP then
vstTasks.FocusedNode:= vstTasks.GetPreviousVisible(Node);
vstTasks.Selected[vstTasks.FocusedNode] := True;
if key in [VK_DOWN,VK_UP] then key := 0;
end;
Can this be simplified? TIA.