TreeView1.Items[i].Selected := true;Well that works; if we check whether the node is selected we get back a TRUE value. However the selection is not indicated visually, the display of the TTreeView component clears all previous selections, and that's all.... no indication of the new selection.
After hours of tedious experiments I finally found the solution: in order to make the component indicate the selection, you have to set the focus to the component (even if it already had the focus before selecting the node). So the following two-liner will do the job:
TreeView1.Items[i].Selected := true;
TreeView1.SetFocus;
Thanks for this Hans; it's always great to get this sort of help.
ReplyDeleteChris Bargh
Thank you very much for this short, simple solution. This is exactly what I've been struggling with, and I think it would have taken quite some time to stumble across your solution.
ReplyDeleteDoug Gardner