EDIT: Answered.

EDIT: Answered. The TTreeView.HideSelection was set to TRUE, so you needed TTreeView.SetFocus() to reflect in the UI the current state of TTreeView.selected<>NIIL. Thanks!



TTreeView.SetFocus() before TTreeView.TTreeNode.selected:=TRUE

After about an hour of trying to set the selected TTreeNode in a TTreeView, I started googling and found this (as well as other links) that indicate you must perform a TTreeView.SetFocus() in order to programatically set the selected TTreeNode.

It works, I plugged the code in and it's working great now.

However, I don't understand why?

Why do you need to SetFocus()? I don't believe you need to do it for a TListView. The only way I remember things, is if I remember the reason for it. Any ideas why? (beyond, "the control needs to have the focus", as that's obvious, but doesn't explain why)

PLATFORM: Delphi 10.2 on Win10 with VCL

Comments