Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When the mouse moves over your button, something similar to the following happens:</p> <ol> <li>The mouse leaves the usercontrol (even though it is still inside the control) and enters the picturebox <ul> <li>Your <code>MouseLeave</code> event handler fires, making the picturebox not visible</li> </ul></li> <li>Because the picturebox isn't visible, the mouse leaves the picturebox and enters the usercontrol <ul> <li>Your <code>MouseEnter</code> event handler fires, making the picturebox visible</li> </ul></li> <li>Because the picturebox is now visible, the process starts over from the beginning</li> </ol> <p>When I tested your code, the "button" flickered continuously (as it kept having its visibility toggled) and was unable to stay visible long enough to register any clicks.</p> <p>One way to address this is to modify your <code>MouseLeaves</code> handler to be something like this:</p> <pre><code>Private Sub NodoEstablo_MouseLeaves(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.MouseLeave If Not ClientRectangle.Contains(PointToClient(Cursor.Position)) Then Me.pictAdd.Visible = False EndIf End Sub </code></pre> <p>This checks to make sure that the mouse has actually left the control before making the button disappear.</p> <p>Changing the size of the picturebox may have broken the cycle outlined above, but it doesn't address the fundamental problem.</p> <p>Here are some other things (that have nothing to do with your question) to consider:</p> <ul> <li>I think that it's recommended that you just override the <code>OnMouseLeaves</code>, etc methods in your usercontrol, instead of subscribing to the corresponding events.</li> <li>Remember that handling controls this way can make it impossible for someone to use your application with a keyboard only. (i.e. the user can't <kbd>Tab</kbd> to your button and press <kbd>Enter</kbd>)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload