During the weekend I had time to test the code from
http://www.originlab.com/forum/topic.asp?TOPIC_ID=3560
It works fine. However there remains one further question. In the code above there's a member function which iterates through the nodes by using a foreach loop on the "Children" data field:
void ShowSequence()
{
foreach(TreeNode tr in m_trNode.Children)
{
AminoAcidResidue aar(tr);
printf("%c", aar.GetType());
}
printf("\n");
}
Since Children is defined a Collection<TreeNode> I tried something like this to access a specific child directly:
Collection<TreeNode> aCollection;
aCollection=m_trNode.Children;
TreeNode myChild;
myChild=aCollection.Item(anIndex); //<<Error, Incompatible variable types in expression
The compiler aborted with the error mentioned in the code above.
If I use an explicit typecast in the marked line:
myChild=(TreeNode)aCollection.Item(anIndex); //<<Error, invalid explicit cast
the copiler still refuses to compile.
I think I'm missing something fundamental. Can somebody please point me to the correct direction? What is the proper way to access a specific item of the Children collection? I know that I could use the TreeNode GetNode (LPCSTR Name)
member function but since I don't know the name, I'd like to access the child by index.
Thanks for your help.
Best regards,
Martin