I have a Treeview which I have the code OK to populate as I need. (Copied from tweaked very slightly)
Now I'm trying to extract the info from it.
The parent nodes consist of a letter pair. Children of that letter pair consist of 2 numbers.
like so:
AA
00
01
BA
11
32
47
etc.
I'm trying to read back the data in format as so:
AA00
AA01
BA11
BA32
BA47
I'm only able to get the parent node text out at all, and depending on what I try, usually only the first and second parent as var both in code below.
Could someone tell me where I am going wrong, as to be honest I don't truly get the Treeview and it's nodes..
I'm using while's as I have no idea how many children each parent could have, or how many parents there might be.
Parents and children will always be 2 letters and 2 numbers though.
My code is meant to get first node, if not nil, get the letters and get child numbers. Add the two together and while next child isn't nil, get the next child and add them together, until all nodes are gone through.
The showmessage would be replaced by code to validate and process the letter number combination.
Steve (Delphi 2007 & XP)
Now I'm trying to extract the info from it.
The parent nodes consist of a letter pair. Children of that letter pair consist of 2 numbers.
like so:
AA
00
01
BA
11
32
47
etc.
I'm trying to read back the data in format as so:
AA00
AA01
BA11
BA32
BA47
I'm only able to get the parent node text out at all, and depending on what I try, usually only the first and second parent as var both in code below.
Could someone tell me where I am going wrong, as to be honest I don't truly get the Treeview and it's nodes..
I'm using while's as I have no idea how many children each parent could have, or how many parents there might be.
Parents and children will always be 2 letters and 2 numbers though.
My code is meant to get first node, if not nil, get the letters and get child numbers. Add the two together and while next child isn't nil, get the next child and add them together, until all nodes are gone through.
The showmessage would be replaced by code to validate and process the letter number combination.
Code:
procedure TMainForm.FindNodesClick(Sender: TObject);
var
TmpNode, TmpChild: TTreeNode;
Both, letters: string;
begin
TmpNode := MainForm.TreeView1.Items.GetFirstNode;
while TmpNode <> nil do
begin
Letters := TmpNode.Text;
while (TmpChild <> nil) do
begin
TmpChild := TmpNode.GetNextSibling;
Both := Letters + TmpChild.Text;
showmessage(Both);
end;
end;
end;
Steve (Delphi 2007 & XP)