Link to home
Start Free TrialLog in
Avatar of SimonYu
SimonYu

asked on

TreeView item search

How to find a item in a TreeView component and expand the node?
ASKER CERTIFIED SOLUTION
Avatar of shenqw
shenqw

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 shenqw
shenqw

'1234' is your wanted selected node's Text
Avatar of SimonYu

ASKER

But how can I expand the selected item node only?
try follow:

procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
begin
  for i:=0 to TreeView1.Items.Count-1 do
    if TreeView1.Items[i].Text='1234' then
    begin
      TreeView1.Items[i].Selected:=True;
      break;
    end;
end;