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

  • SEARCH
  • Home
  • 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 553303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:35:27+00:00 2026-05-13T11:35:27+00:00

I have a simple situation (.NET2): a texbox1 on a UserControl1(or Form1). I want

  • 0

I have a simple situation (.NET2): a texbox1 on a UserControl1(or Form1).

I want to unfocus(leave) the texbox when I click on the usercontrol/form(focus the usercontrol/form instead):
alt text http://lh3.ggpht.com/_1TPOP7DzY1E/S0R1ORVt-pI/AAAAAAAAC3Y/UkS2zEMWa9o/s800/Capture4.png

I do the following on the UC/form:

      Protected Overrides Sub OnMouseClick _
          (ByVal e As System.Windows.Forms.MouseEventArgs)
        MyBase.OnMouseClick(e)
        Me.Focus()
      End Sub

Why does it not work on the child textbox, but works very well on the non-child one(focus on textBox2 then click on the panel removes the focus from the textBox2)?

Real project Window

alt text http://lh5.ggpht.com/_1TPOP7DzY1E/S0SVniaeN1I/AAAAAAAAC3g/jafhFG-vA0g/s800/Capture5.png

  • 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. Editorial Team
    Editorial Team
    2026-05-13T11:35:27+00:00Added an answer on May 13, 2026 at 11:35 am
    1. Add a new panel control to your form (somewhere out of the way) and resize it to 0,0
    2. Do NOT set Visible = false on this panel.
    3. In your form add a standard MouseClick event handler as follows:

      private void Form1_MouseClick(object sender, MouseEventArgs e)
      {
          // Uncomment if in scrollable control
          //Point scrollPos = new Point(this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);
          newPanel.Select(); 
          // Uncomment if in scrollable control
          //this.AutoScrollPosition = scrollPos;
      
      }
      
    4. Now, when you click anywhere on your main form, any input control will lose focus and you will be able to handle the usual Validating events etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple situation here. lets face html code first => <form name=geoKey
I have simple php validation form that is halfway working. If you leave the
Simple situation(VS2005, .NET2): I have a textBox1 on a panel1. I need to track
I have simple situation: I know both (user) UID and password and I want
Simple situation One object User have many UserGroups. I want to implement on mvc3
I have a simple parent-child situation where the parent can have multiple children. The
My situation is simple. I have this in my program: File folder = new
I have a situation in C# where I have a list of simple types.
The situation is very simple, I have two panel. In the event of OnMouseOver
I have a simple situation. A large organisation is using several different versions of

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.