在我的方法中选择事件后调用树视图节点 [英] Call the tree view node after select event in my method
本文介绍了在我的方法中选择事件后调用树视图节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在下面的选择事件之后有树视图节点。
private void treeView1_AfterSelect(object sender,TreeViewEventArgs e)
{
ifcViewerWrapper._treeData.OnAfterSelect(sender,e);
}
所以我需要用我的方法调用那个事件。
private void FindRecursive(TreeNode treeNode)
{
foreach (TreeNode tn in treeNode.Nodes)
{
if (tn.Text.Contains( this .toolStripTextBox1.Text))
{
// 调用treeView1_AfterSelect事件
}
FindRecursive(TN);
}
}
有人可以帮我这样做
问候
Ruwan Atapattu
解决方案
你没有打电话事件处理程序:使用正确机制进入处理程序,事件需要正确引发 - 这是你无法做到的,因为TreeView中没有人工引发的机制,而事件没有确实发生了。
相反,将事件处理程序中的代码删除为普通方法,并使用适当的参数值(在您的情况下为Node)调用该代码。 / BLOCKQUOTE>
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.
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解决方案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.
这篇关于在我的方法中选择事件后调用树视图节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文