选择正确的事件处理程序
我有一个treeview
,它有树节点数据库,数据库有表。我想在单击表名称时显示列表视图。我必须使用哪个事件处理程序?我尝试了 treenodemouseclick
、treenodemousedoubleclick
和 mouseclick
处理程序,但没有效果。请帮忙。
I have a treeview
which have as treenodes databases and databases have tables. I want to show listview when I click on the table name. Which eventhandler do I have to use for that? I tried treenodemouseclick
, treenodemousedoubleclick
and mouseclick
handlers, but there was no effect. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常我使用 AfterSelectEvent ,它会在事件参数上引用选定的节点:
然后您只需要根据您获得的节点来处理事件。
祝你好运,
复仇女神
Normally I use AfterSelectEvent which brings a reference to the selected node on the event argument:
Then you just need to treat the event depending on the node you get.
Good luck,
Nemesis
您是在谈论
Windows.Forms.TreeView
吗?如果是这样,并且您正在处理节点选择,则需要
BeforeSelect
或AfterSelect
事件。BeforeSelect
将让您确定将要选择哪个节点并做出相应响应,甚至在需要时取消节点选择。如果您不想尝试对节点选择执行任何特定操作,但希望对某些选择(或每个选择)执行额外的工作,则
AfterSelect
是最好的选择。http://msdn.microsoft.com/en-us /library/system.windows.forms.treeview.aspx
Are you talking about
Windows.Forms.TreeView
?If so, and you are dealing with selection of nodes, you want the
BeforeSelect
orAfterSelect
event.BeforeSelect
will let you determine which node is about to be selected and respond accordingly or even cancel the node selection if need be.AfterSelect
is best if you aren't trying to do anything specific with node selection, but you want to perform additional work for certain selections (or every selection).http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aspx