Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have tree view node after select event like below.

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
ifcViewerWrapper._treeData.OnAfterSelect(sender, e);

}
So i need call that event in my my method.

C#
private void FindRecursive(TreeNode treeNode)
    {
        foreach (TreeNode tn in treeNode.Nodes)
        {
          
            if (tn.Text.Contains(this.toolStripTextBox1.Text))
            {
               
//call the  treeView1_AfterSelect event
            }
            FindRecursive(tn);
        }
    }



can some one help me to do this

Regards
Ruwan Atapattu
Posted
Comments
BillWoodruff 30-Nov-13 22:35pm    
I can't understand what you are asking: what is the connection between the code shown in the AfterSelect EventHandler and the recursive find procedure ? What are you trying to do here ?
ruwan_t 30-Nov-13 23:39pm    
I just need to run the method (fcViewerWrapper._treeData.OnAfterSelect(sender, e)) inside the treeView1_AfterSelect.

the implementation of this mothod is

public void OnAfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Tag == null)
{
// skip properties
return;
}

if (e.Node.ImageIndex != IMAGE_CHECKED)
{
// skip unvisible & not referenced items
return;
}

_ifcViewer.SelectItem((e.Node.Tag as IFCTreeItem).ifcItem);
}
BillWoodruff 30-Nov-13 23:41pm    
Your OnAfterSelect code looks fine; what's the problem calling this method from the TreeView AfterSelect EventHandler ?

Might be helpful here if you describe what the IFCViewer is and its relationship to your application, and the TreeView.
Karthik_Mahalingam 30-Nov-13 22:54pm    
web or windows??
add more info to your question
ruwan_t 30-Nov-13 23:19pm    
Windows

1 solution

You don't "call" event handlers: to use the "proper" mechanism to get into the handler, the event needs to be raised properly - which you can't do since there is no mechanism within a TreeView to artificially "raise" and event when it didn't really happen.

Instead, remove the code from your event handler into a "normal" method and call that with the appropriate parameter value - the Node in your case.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900