Help setting for parent

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

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

In UC / form, I do the following:

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

Why doesn’t it work with the child text field , but it works fine on the non-child text field (focus on textBox2, then click on the panel, removes focus from textBox2)?

Real project window

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

+3
4
  • (- ) 0,0
  • Visible = false .
  • MouseClick :

    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;
    
    }
    
  • , , , ..
+3

Form, UserControl. , , - , . ContainerControl, . GroupBox - .

, : , , , , .

, .

+2

, , Excel. , ( ), , , .

, Excel.

, , . . , ( "", , ) , UserControl. usercontrol :

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

, . , , , , .

, , , .

+2

. .

0

Source: https://habr.com/ru/post/1727473/


All Articles