Solved

TreeView item search

Posted on 2000-04-21
4
241 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

617 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