Help setting focus on the parent

Posted by serhio on Stack Overflow See other posts from Stack Overflow or by serhio
Published on 2010-01-06T11:41:57Z Indexed on 2010/04/07 22:13 UTC
Read the original article Hit count: 229

Filed under:
|
|
|
|

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

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

© Stack Overflow or respective owner

Related posts about .NET

Related posts about focus