Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to compare the items in a TStringList with the items in the child nodes of a Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
26-Sep-02
Category
VCL-General
Language
Delphi 2.x
Views
172
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I would like to compare the items in a TStringList with the child nodes of the 
selected node in a TTreeView and instead of deleting the matching nodes, change the 
image of the node to one from a TImageList component.

Answer:

Solve 1:

Something like:

1   var
2     T: TTreeNode;
3   begin
4     {Point at the first child of the selected node}
5     T := TreeView.Selected.GetFirstChild;
6     {Loop over all children of this node}
7     while Assigned(T) do
8     begin
9       {Compare T.Text against contents of a listbox, or whatever...}
10      {T set to nil if Selected has no more children}
11      T := TreeView.Selected.GetNextChild(T);
12    end;
13  end;


Note this only works with direct children of the Selected node; if you may have to 
deal with deeper levels in the tree then it gets (marginally) more complex.


Solve 2:

Try one of these:

14  { ... }
15  for i := 0 to TreeView1.Selected.Count - 1 do
16    if ListBox1.Items.IndexOf(TreeView1.Selected.Item[i].Text) >= 0 then
17      TreeView1.Selected.Item[i].ImageIndex := 4;
18  { ... }
19  
20  var
21    child: TTreeNode;
22    { ... }
23    child := TreeView1.Selected.GetFirstChild;
24    while Assigned(child) do
25    begin
26      if ListBox1.Items.IndexOf(child.Text) >= 0 then
27        child.ImageIndex := 4;
28      child := child.GetNextSibling
29    end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC