树视图项目在VB中单击 [英] Tree view item click in vb

查看:132
本文介绍了树视图项目在VB中单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个treeview,我正在为其动态填充项目.单击任何项​​目时,它必须导航到导航框架的URL中指定的页面.第一次单击时,它可以正确导航,但是在第二次单击时,不会触发选择树视图的事件.仅当我单击其他树状视图项目并单击上一个项目时,它才会再次被触发.可能是什么问题呢?我该如何解决?

在此先感谢,
问候.

Hello All,

I have a treeview for which i am filling the items dynamically. On clicking any item it has to navigate to the page specified in the url of the navigation frame. On first click it is navigating properly but on second click the treeview selected event is not getting fired. It only gets fired again when i click on someother tree view item and click back on my previous item. What could be the problem? How can i fix this?

Thanks in Advance,
Regards.

推荐答案

该节点已被选中,因此如果您再次单击所选节点,则所选事件将不会再次触发.

如果您希望每次单击都会发生某事,无论是否选中它,请使用NodeMouseClick

演示;

The node is already selected, so the selected event will not fire again if you click the selected node a second time.

If you want something to happen everytime you click it, regardless if it is selected or not, use NodeMouseClick

Demo;

'Add 3 Roots each with 3 children
    For i = 0 To 2
        Dim node As New TreeNode("Item" + i.ToString)

        For j = 0 To 2
            Dim childnode As New TreeNode("Child" + j.ToString)
            node.Nodes.Add(childnode)
        Next

        TreeView1.Nodes.Add(node)
    Next
End Sub

Private Sub TreeView1_NodeMouseClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
    Debug.WriteLine(e.Node.Text)
End Sub


这篇关于树视图项目在VB中单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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