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)?
alt text http://lh5.ggpht.com/_1TPOP7DzY1E/S0SVniaeN1I/AAAAAAAAC3g/jafhFG-vA0g/s800/Capture5.png
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; }
Form, UserControl. , , - , . ContainerControl, . GroupBox - .
, : , , , , .
, .
, , Excel. , ( ), , , .
, Excel.
, , . . , ( "", , ) , UserControl. usercontrol :
Protected Overrides Sub OnMouseClick _ (ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseClick(e) myFakeTextBox.Focus() End Sub
, . , , , , .
, , , .
. .
Source: https://habr.com/ru/post/1727473/More articles:Java GUI Toolbar - javaProblem in Java GUI - javaRemoving files and folders when deleting - windows-installerEquivalence Selector - jqueryWhy is ASP code unavailable? - vbscriptHow to copy ntext column value to new non-zero column - sqlVS DataBreakpoints: разница между C и С++ - c++ASP.NET MVC OutputCacheAttribute: don't cache if option is set? - cachingHow to get gridview data source - c #Agnostic Connection handlers in .NET. - c #All Articles