开发者

How can I make a TreeNode change the cursor when the mouse hovers over it?

I have created a menu using a treeview to launch forms when the user clicks on a node. To complete the look-and-feel, I have set up the nod开发者_开发技巧es to look like hyperlinks. I'd like to have the cursor change to a hand (like the one you see when you hover over a link) when the user hovers over a node, however so far I've only been able to have the cursor change on hovering inside the treeview, as opposed to over a node. As far as I can tell, a TreeNode doesn't have events such as MouseEnter, so I can't have them handle the events themselves.

I am attempting to use this function to loop through the nodes and check the Bounds property of the TreeNode against the Point property of the cursor, but so far the If block always evaluates to false, meaning that the cursor never changes.

Private Sub uxNavigationTreeView_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxNavigationTreeView.MouseHover
    For Each node As TreeNode In uxNavigationTreeView.Nodes
        For Each child As TreeNode In node.Nodes
            If child.Bounds.IntersectsWith(New Rectangle(Cursor.Position, New Size(1, 1))) Then
                Me.Cursor = Cursors.Hand
            End If
        Next
    Next
End Sub

I was hoping that someone could point me in the right direction to accomplish this. In essence, I am looking for the look-and-feel of a nested LinkButton array.


Use the MouseMove event. Call the HitTest() method.


Cursor.Position returns the mouse pointer position in screen coordinates - use uxNavigationTreeView.PointToClient to convert the position to client coordinates and I think you'll then have more luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜