Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 164425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:44:31+00:00 2026-05-11T11:44:31+00:00

I have a userControl (.NET 1.1 Winforms) that has a clickable picturebox as a

  • 0

I have a userControl (.NET 1.1 Winforms) that has a clickable picturebox as a button.

Since I have lots of those usercontrols visible at the same time, I thought It could be nice if I just display the picture box when the mouse is over the usercontrol and hide it otherwise.

To do so, I handle the MouseEnter and MouseLeave events of the UserControl, hiding and displaying the picturebox. That works fine.

But when the clickable picturebox is visible I’m not longer able to click it (the hand cursor is gone and the click event is not firing).

After some test, I realize that if comment all content on the MouseLeave handler that do something with my picturebox… this way the picturebox is clickable.

I’m not using the correct event?

There’s another way to accomplish this?

Here is the code…

Private Sub NodoEstablo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     Me.pictAdd.Visible = False  End Sub   Private Sub NodoEstablo_MouseEnters(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseEnter             Me.pictAdd.Visible = True End Sub 

The problematic event handler:

Private Sub NodoEstablo_MouseLeaves(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave     Me.pictAdd.Visible = False End Sub 

Update: If I resize the picturebox on MouseLeave (just to do something) it works. So far, changing Visible and Location in the MouseLeave prevent me for click the picturebox. :S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:44:32+00:00Added an answer on May 11, 2026 at 11:44 am

    When the mouse moves over your button, something similar to the following happens:

    1. The mouse leaves the usercontrol (even though it is still inside the control) and enters the picturebox
      • Your MouseLeave event handler fires, making the picturebox not visible
    2. Because the picturebox isn’t visible, the mouse leaves the picturebox and enters the usercontrol
      • Your MouseEnter event handler fires, making the picturebox visible
    3. Because the picturebox is now visible, the process starts over from the beginning

    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.

    One way to address this is to modify your MouseLeaves handler to be something like this:

    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 

    This checks to make sure that the mouse has actually left the control before making the button disappear.

    Changing the size of the picturebox may have broken the cycle outlined above, but it doesn’t address the fundamental problem.

    Here are some other things (that have nothing to do with your question) to consider:

    • I think that it’s recommended that you just override the OnMouseLeaves, etc methods in your usercontrol, instead of subscribing to the corresponding events.
    • 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 Tab to your button and press Enter)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What is happening here is that std::cin >> firstName; only… May 11, 2026 at 4:30 pm
  • Editorial Team
    Editorial Team added an answer I prefer to write a managed wrapper in C++/CLI (formerly… May 11, 2026 at 4:30 pm
  • Editorial Team
    Editorial Team added an answer You can, but it would be unusual for it to… May 11, 2026 at 4:30 pm

Related Questions

I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The
I'm having some fun trying to get my head around some MVP stuf, as
I need a UserControl to display pictures as a Gallery in Winforms. I have
Looking for some direction here as I'm running into some migration problems. We have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.