How to: Set Focus in a TextBox Control
This example shows how to use the Focus method to set focus on a TextBox control.
Define a simple TextBox control
The following Extensible Application Markup Language (XAML) example describes a simple TextBox control named tbFocusMe
<TextBox Name="tbFocusMe">
This is the text in my text box.
</TextBox>
Set the focus on the TextBox control
The following example calls the Focus method to set the focus on the TextBox control with the Name tbFocusMe.
tbFocusMe.Focus();
tbFocusMe.Focus()
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET Desktop feedback