Page 1 of 1

Repeatedly find items that contain the same string

Posted: Mon May 11, 2009 3:27 pm
by 9345067
In an application I want to find all nodes that contain eg. the words "plot.plott".

I do not find a method that repeatedly give me the next node that fit the word, only the first node as in the TreeRoots.pas example.

Is the needed action not available or do I miss something obvious ??

Re: Repeatedly find items that contain the same string

Posted: Thu Jun 18, 2009 8:57 pm
by Tom
There is no method to retrieve nodes as such, however, you can implement this on a relatively easy way. The Shapes property contains all the nodes in the tree, so you can iterate these and perform your match on every node, as in:

Code: Select all

procedure TForm2.FindNodesClick(Sender: TObject);
var t: integer;
begin
  for t:=0 to Tree1.Shapes.Count-1 do
  if (Pos('TreeNode',Tree1.Shapes[t].SimpleText)>0)then
  begin
    Showmessage(Tree1.Shapes[t].Name);
  end;
end;
Regards,
Tom.