Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TreeView item search

Posted on 2000-04-21
4
Medium Priority
?
242 Views
Last Modified: 2010-05-18
How to find a item in a TreeView component and expand the node?
0
Comment
Question by:SimonYu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
shenqw earned 200 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! 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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

722 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