Link to home
Start Free TrialLog in
Avatar of evansj
evansj

asked on

Detecting when an object in the tree view component is selected

How do you determine if an object in the tree view component has been selected or not? Secondly, how would you select an object in code?
Avatar of jeurk
jeurk

use the treeview.selected to get thecurrent
selected items.

if TreeView1.Selected = nil then Exit;

AnItem: TTreeNode;

AnItem:= TreeView1.Selected to retrieve
teh selected one.

To select an item by code put it's
selected property at true.

select the root of your tree :
treeview1.items[0].selected := True;
i hope it's what you want ;)
Additionally, for each change in a tree view (also selection changes) the OnCHange event is triggered. So you can keep track of all things the user is doing. If you have sometimes many changes occuring in a row which might be time costly to handle each and all then use the ChangeDelay property of the tree view. If this property is > 0 the a timer is restarted each time a change occurs and only if this timer is not retriggered while waiting for its interval to timeout the OnChange event is called.

Ciao, Mike
Avatar of evansj

ASKER

What I want to do is make sure an item in the tree has been selected or not. I won't know which one until the user selects it.
ASKER CERTIFIED SOLUTION
Avatar of jeurk
jeurk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of evansj

ASKER

Thanks lots!!!!
You're welcome.