用于treenode的ContextMenuStrip [英] ContextMenuStrip for treenode

查看:59
本文介绍了用于treenode的ContextMenuStrip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在使用contextmenustrip来获取treenode;如何确定哪个树节点当前具有上下文菜单条?我正在尝试使用contextmenustrip位置,但它引用了错误的树节点。


谢谢。

解决方案

< blockquote>

我没有清楚地理解你,你想说的是,例如,如果用户按下右键单击某个树节点,那么当你尝试使用SelectedNode属性时,它指的是一个错误的树节点,如果这就是你的意思?然后使用下面的事件及其代码(可能有帮助):



私人 Sub MyTreeView_NodeMouseClick( ByVal 发件人 As 对象 ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) 句柄 MyTreeView.NodeMouseClick


MyTreeView.SelectedNode = e.Node


结束 Sub



这确保每当用户按下左键单击或右键单击时,SelectedNode参数将为al方法是正确的。


如果您想说另一件事,请发布您的代码,我们稍后会讨论。



Salan S. Al-Ani


Hello,

I'm using a contextmenustrip for a treenode; how do I figure out which tree node currently has the context menu strip for it?  I'm trying to use the contextmenustrip location, but it references the wrong tree node.

Thanks.

解决方案

I did not understand you clearly, are you trying to say that for example if a user press right click to a certain tree node then when you are trying to use the SelectedNode property it refers to a wrong tree node, if this what you are ment? then use the below event and its code (it might help):

 

Private Sub MyTreeView_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles MyTreeView.NodeMouseClick

MyTreeView.SelectedNode = e.Node

End Sub

 

This ensure that whenever the user press left click or right click then the SelectedNode parameter will be always correct.

If you are trying to say another thing, please post your code and we will discuss later.

 

Salan S. Al-Ani


这篇关于用于treenode的ContextMenuStrip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆