Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Mouse over: Border, else not!

Posted on 2004-10-23
Medium Priority
Last Modified: 2010-04-23

I have a label and now I want to do this:

If I move the mouse over the label, the border around the label should appear, if I move away from the label the border should disappear

It's clear to use the mouse_enter and mouse_leave-property and that is working correctly but the problem is the following:

If I activate the border, the text in the label will move one pixel to right and to the bottom. To equilaze that I have used:

    Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
        Label1.Top = Label1.Top - 1
        Label1.Left = Label1.Left - 1
        Label1.BorderStyle = BorderStyle.FixedSingle
    End Sub

    Private Sub Label1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave
        Label1.Top = Label1.Top + 1
        Label1.Left = Label1.Left + 1
        Label1.BorderStyle = BorderStyle.None
    End Sub

But that's not working correctly. It is activating the border but if I leave the label with the mouse on the botton or right border the border is not disappearing...

How can I solve that?

Thanks a lot

Question by:Dumdidum
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Accepted Solution

Gregory Miller earned 180 total points
ID: 12389509
Draw the label using the default form background color and leave the border drawn at all times. The MouseEnter and MouseLeave events should simply change the color of the border. This will prevent the need to compensate for the movement of the text and should simplify the border display on and off visual effect you are looking for.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question