Solved

TreeView item search

Posted on 2000-04-21
4
229 Views
Last Modified: 2010-05-18
How to find a item in a TreeView component and expand the node?
0
Comment
Question by:SimonYu
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
shenqw earned 100 total points
ID: 2739476
procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
  Node:TTreeNode;
begin
  TreeView1.AutoExpand:=True;
  for i:=0 to TreeView1.Items.Count-1 do
    if TreeView1.Items[i].Text='1234' then
    begin
      TreeView1.Selected:=TreeView1.Items[i];
      break;
    end;
end;
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2739480
'1234' is your wanted selected node's Text
0
 

Author Comment

by:SimonYu
ID: 2740112
But how can I expand the selected item node only?
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2740191
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;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now