Foxtable(狐表)用户栏目专家坐堂 → 目录树光标停留节点突出显示


  共有2162人关注过本帖树形打印复制链接

主题:目录树光标停留节点突出显示

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/23 10:38:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/23 11:18:00 [显示全部帖子]

mouseMove事件

 

'static ptime As Date = Nothing
'Dim sp As TimeSpan = Date.now - ptime
'ptime = Date.now
'If sp.TotalMilliseconds < 50  Then '间隔1000毫秒
    'Return
'End If
static pnd As object
Dim tree As windows.Forms.treeview = e.sender.basecontrol
Dim x As Integer = System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = System.Windows.Forms.Cursor.Current.Position.Y
Dim pt = tree.PointToClient(new Point(X, Y))  '取当前坐标
Dim nd As System.Windows.Forms.TreeNode = tree.GetNodeAt(pt) '取坐标所在位置的节点
If nd Is Nothing OrElse pnd Is Nothing OrElse pnd.name <> nd.name Then
    For i As Integer = tree.Controls.Count - 1 To 0 Step -1
        If tree.Controls(i).Name = "SelectLab" Then
            tree.Controls.RemoveAt(i)
        End If
    Next
    If nd IsNot Nothing
        Dim selCon As  System.Windows.Forms.Control = tree.Controls("SelectLab")
        Dim label As New System.Windows.Forms.Label
        label.Name = "SelectLab"
        label.AutoSize = False
        label.BackColor = Color.Red
        label.ForeColor = nd.ForeColor
        label.Font = new font(tree.Font.name, tree.Font.size, FontStyle.Bold )
        tree.Controls.Add(label)
        selCon = Label
        Dim node As System.Windows.Forms.TreeNode = nd
        selCon.Size = new Size(node.Bounds.Width+5, node.Bounds.Height)
        selCon.Location = new Point(node.Bounds.X, node.Bounds.Y)
        selCon.Text = nd.Text
    End If
End If
pnd = nd


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/23 16:45:00 [显示全部帖子]

你nodemouseclick事件的代码,写到afterSelectNode事件去,然后

 

全局代码

 

Public Sub lbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    sender.parent.selectedNode = sender.tag
End Sub

 

mousemove事件

 

'static ptime As Date = Nothing
'Dim sp As TimeSpan = Date.now - ptime
'ptime = Date.now
'If sp.TotalMilliseconds < 50  Then '间隔1000毫秒
'Return
'End If
static pnd As object
Dim tree As windows.Forms.treeview = e.sender.basecontrol
Dim x As Integer = System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = System.Windows.Forms.Cursor.Current.Position.Y
Dim pt = tree.PointToClient(new Point(X, Y))  '取当前坐标
Dim nd As System.Windows.Forms.TreeNode = tree.GetNodeAt(pt) '取坐标所在位置的节点
If nd Is Nothing OrElse pnd Is Nothing OrElse pnd.name <> nd.name Then
    For i As Integer = tree.Controls.Count - 1 To 0 Step -1
        If tree.Controls(i).Name = "SelectLab" Then
            tree.Controls.RemoveAt(i)
        End If
    Next
    If nd IsNot Nothing
        Dim selCon As  System.Windows.Forms.Control = tree.Controls("SelectLab")
        Dim label As New System.Windows.Forms.Label
        label.Name = "SelectLab"
        label.AutoSize = False
        label.BackColor = Color.Red
        label.ForeColor = nd.ForeColor
        label.Font = new font(tree.Font.name, tree.Font.size, FontStyle.Bold )
        tree.Controls.Add(label)
        selCon = Label
        Dim node As System.Windows.Forms.TreeNode = nd
        selCon.Size = new Size(node.Bounds.Width+5, node.Bounds.Height)
        selCon.Location = new Point(node.Bounds.X, node.Bounds.Y)
        selCon.Text = nd.Text
        selCon.tag = nd
        AddHandler selCon.Click, AddressOf lbl_Click
    End If
End If
pnd = nd


 回到顶部