I need to select a specific node in VirtualTreeview programmatically, but I don't find any method to do so. Anybody could help with a solution?
Asked
Active
Viewed 3,240 times
2
-
1`VirtualTree.Selected[NodeOfYourChoice] := True;` – TLama Feb 02 '15 at 12:41
-
1Presumably preceded by `VirtualTree.ClearSelection;` – David Heffernan Feb 02 '15 at 12:41
-
...if you use multiselect. – TLama Feb 02 '15 at 12:43
-
Wow, that was fast ! – Willer Bononi Feb 02 '15 at 12:44
-
See also [How to select all root or all child nodes in VirtualStringTree?](http://stackoverflow.com/q/12142258/576719). – LU RD Feb 02 '15 at 12:46
-
Interestingly this changes visually the focus in the tree but focusednode remains the same... – Willer Bononi Feb 02 '15 at 12:50
-
Uhn... I got this. Changing the focusednode to the one seems to work... [code]VirtualTree.focusednode:=NodeSelected – Willer Bononi Feb 02 '15 at 12:54
1 Answers
6
Select nodes like this:
VirtualTree.Selected[Node] := True;
If you have a multi-select tree then precede this by clearing any existing selection:
VirtualTree.ClearSelection;

David Heffernan
- 601,492
- 42
- 1,072
- 1,490
-
This worked for me to select the node but later in the code I am attempting to grab the .FocusedNode but this is nil. Is there something else I can do to 'focus' the node also? The node seems to be focused when I actually click the node but not when doing it programatically using .selected[Node] := true. – Charles S May 08 '19 at 19:10