treeview control continous...

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
H

Hrvoje Voda

I manage to fill treeview control with data and I would like to search
through that data.

In child I have names of films, and when I click on one of them I would like
to show it's information in grid.
How?

Hrcko
 
In answer to your first question, you have to iterate your TreeNodes
recursively, such as

private TreeNode SearchNodes(string nodeName)
{
foreach(TreeNode node in myTreeView.Nodes)
{
if (string.Compare(nodeName, nodeText, true) == 0)
{
return node;
}
TreeNode foundNode = null;
foreach(TreeNode childNode in node.Nodes)
{
foundNode = SearchNodes(nodeName);
if (foundNode != null)
{
return foundNode;
}
}
}
return null;
}


As for your second question, just handle the AfterSelect event of your
TreeView and then use the SelectedNode property to determine which node was
selected.

HTH,

DalePres
MCAD, MCDBA, MCSE
 
What is nodeText in this function?

Hrcko


DalePres said:
In answer to your first question, you have to iterate your TreeNodes
recursively, such as

private TreeNode SearchNodes(string nodeName)
{
foreach(TreeNode node in myTreeView.Nodes)
{
if (string.Compare(nodeName, nodeText, true) == 0)
{
return node;
}
TreeNode foundNode = null;
foreach(TreeNode childNode in node.Nodes)
{
foundNode = SearchNodes(nodeName);
if (foundNode != null)
{
return foundNode;
}
}
}
return null;
}


As for your second question, just handle the AfterSelect event of your
TreeView and then use the SelectedNode property to determine which node
was selected.

HTH,

DalePres
MCAD, MCDBA, MCSE
 
Back
Top