Results 1 to 5 of 5

Thread: [RESOLVED] Make Visble When Mouse Is Over.

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    50

    Resolved [RESOLVED] Make Visble When Mouse Is Over.

    I'm trying to make a code that say's:

    when the mouse is in the area of the toolbox1 then the toolbox1

    becomes visble when he leaves, it becomes invisble.

    It's simble but i can't find it.

    and if it's possible like it falls down.




    Thanks, Dwight

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Make Visble When Mouse Is Over.

    try this. just set your toolstrip control's visible property to false in your designer, then add this code:

    vb Code:
    1. Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    2.     If e.Y < 25 Then
    3.         ToolStrip1.Visible = True
    4.     Else
    5.         ToolStrip1.Visible = False
    6.     End If
    7. End Sub

    edit: change 25 to your toolstrip's height

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    50

    Re: Make Visble When Mouse Is Over.

    The code your posted works, i changed the height to 37.

    but it don't become invisble again.

    My mouse goes over it and it's visble, when it leaves it's still visble.

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Make Visble When Mouse Is Over.

    Quote Originally Posted by Dwight-Pre View Post
    The code your posted works, i changed the height to 37.

    but it don't become invisble again.

    My mouse goes over it and it's visble, when it leaves it's still visble.
    What about using the ToolStrips MouseLeave event?

    Code:
        Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
            If e.Y < ToolStrip1.Height Then
                ToolStrip1.Visible = True
                ToolStrip1.BringToFront()
            End If
        End Sub
    
        Private Sub ToolStrip1_MouseLeave(sender As Object, e As System.EventArgs) Handles ToolStrip1.MouseLeave
            ToolStrip1.Visible = False
        End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    50

    Re: Make Visble When Mouse Is Over.

    (sorry, but i didn't know that there was a MouseLeave sub)
    Works Perfect!


    Thank you Edgemeal and Paul for the big help!

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