Results 1 to 11 of 11

Thread: [RESOLVED] Change cursor when hover nodes of treeview (help me please....)

  1. #1

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Resolved [RESOLVED] Change cursor when hover nodes of treeview (help me please....)

    I want when i hover my mouse to nodes of treeview the cursor is hand type.

    Code:
    Private Sub TREEVIEW2_(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeView1.NodeMouseHover
    
            Me.TreeView1.Cursor = Cursors.Hand
    
        End Sub
    I did this. But i want when i leave nodes the cursor back to default.
    Last edited by manhit45; Jul 20th, 2009 at 04:06 AM.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: To cursor.Hand when hover nodes.

    Hi,
    There's a mouseNodeHover event.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: To cursor.Hand when hover nodes.

    Quote Originally Posted by sparrow1 View Post
    Hi,
    There's a mouseNodeHover event.
    I used it above. did you read my post carefully.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  4. #4
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Change cursor when hover nodes of treeview (help me please....)

    Private Sub TREEVIEW2_....
    Where is the rest m8

    Shouldn't it be :
    vb.net Code:
    1. Private Sub TREEVIEW2_NodeMouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeView1.NodeMouseHover


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  5. #5
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Change cursor when hover nodes of treeview (help me please....)

    Quote Originally Posted by Radjesh Klauke View Post
    Private Sub TREEVIEW2_....
    Where is the rest m8

    Shouldn't it be :
    vb.net Code:
    1. Private Sub TREEVIEW2_NodeMouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeView1.NodeMouseHover
    The name of the sub is totally irrelevant, the only important bit is the Handles clause at the end. Unlike VB6 and earlier where the name of the routine had to be the event name.

  6. #6

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: Change cursor when hover nodes of treeview (help me please....)

    Quote Originally Posted by Radjesh Klauke View Post
    Private Sub TREEVIEW2_....
    Where is the rest m8

    Shouldn't it be :
    vb.net Code:
    1. Private Sub TREEVIEW2_NodeMouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeView1.NodeMouseHover
    It doesnt effect to my code. Please tell me. when i leave nodes i want the cursor back to default.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  7. #7
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Change cursor when hover nodes of treeview (help me please....)

    Hi,

    After some research I think you'll need the OnmouseHover method to do so.
    Here's the link.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  8. #8

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: Change cursor when hover nodes of treeview (help me please....)

    Quote Originally Posted by sparrow1 View Post
    Hi,

    After some research I think you'll need the OnmouseHover method to do so.
    Here's the link.
    i have just read that document but i cant find out solution for my trouble.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  9. #9
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Change cursor when hover nodes of treeview (help me please....)

    The MouseHover method applies to the treeview not the node.

    Hovering events are no use anyway because you would need a "StoppedHovering" event to tell you when the hovering had stopped.

    You'll need something like this :

    Code:
        Private Sub TreeView1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseMove
    
            If CType(sender, TreeView).GetNodeAt(New Point(e.X, e.Y)) Is Nothing Then
                Me.TreeView1.Cursor = Cursors.Hand
            Else
                Me.TreeView1.Cursor = Cursors.Default
            End If
    
        End Sub
    Note that doesn't actually work - haven't had chance to test it properly yet and going to have to dash. I suspect e.X and e.Y are returning screen co-ordinates rather than the co-ordinates within the control, but that should be easy enough to fix.

  10. #10

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: Change cursor when hover nodes of treeview (help me please....)

    Thanks Paul (You miss 'not' keyword)

    I remembered vaguely about that method but i cant do exactly as you.

    Thanks again.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  11. #11
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] Change cursor when hover nodes of treeview (help me please....)

    Sorry - quite right.. daft mistake - I was in a rush.
    Last edited by keystone_paul; Jul 20th, 2009 at 05:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width