Solved

TreeView item search

Posted on 2000-04-21
4
226 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
Comment Utility
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
Comment Utility
'1234' is your wanted selected node's Text
0
 

Author Comment

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

Expert Comment

by:shenqw
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

12 Experts available now in Live!

Get 1:1 Help Now