选择正确的事件处理程序

发布于 2024-11-04 05:53:41 字数 194 浏览 1 评论 0原文

我有一个treeview,它有树节点数据库,数据库有表。我想在单击表名称时显示列表视图。我必须使用哪个事件处理程序?我尝试了 treenodemouseclicktreenodemousedoubleclickmouseclick 处理程序,但没有效果。请帮忙。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戏剧牡丹亭 2024-11-11 05:53:44

通常我使用 AfterSelectEvent ,它会在事件参数上引用选定的节点:

    private void TvwTraining_AfterSelect(object sender, TreeViewEventArgs e)
    {

        if (e.Node.Parent == null)
        {
            // Its a top level node
            ParentObject ParentObj = (ParentObject)e.Node.Tag;
            ShowParentDetails(ParentObj);
        }

        else
        {
            // Its a child node
            ChildObject ChildObj = (ChildObject)e.Node.Tag;
            ShowChildDetails(ChildObj);
        }

    }

然后您只需要根据您获得的节点来处理事件。

祝你好运,
复仇女神

Normally I use AfterSelectEvent which brings a reference to the selected node on the event argument:

    private void TvwTraining_AfterSelect(object sender, TreeViewEventArgs e)
    {

        if (e.Node.Parent == null)
        {
            // Its a top level node
            ParentObject ParentObj = (ParentObject)e.Node.Tag;
            ShowParentDetails(ParentObj);
        }

        else
        {
            // Its a child node
            ChildObject ChildObj = (ChildObject)e.Node.Tag;
            ShowChildDetails(ChildObj);
        }

    }

Then you just need to treat the event depending on the node you get.

Good luck,
Nemesis

倾城°AllureLove 2024-11-11 05:53:44

您是在谈论Windows.Forms.TreeView吗?

如果是这样,并且您正在处理节点选择,则需要 BeforeSelectAfterSelect 事件。

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 or AfterSelect 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文