| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Set Focus in a TextBox Control |
03/30/2017 |
.net-framework |
|
article |
|
24b61b45-dc2d-425e-9839-b017af7ab86f |
11 |
dotnet-bot |
dotnetcontent |
wpickett |
How to: Set Focus in a TextBox Control
This example shows how to use the xref:System.Windows.UIElement.Focus%2A method to set focus on a xref:System.Windows.Controls.TextBox control.
Example
The following [!INCLUDETLA#tla_xaml] example describes a simple xref:System.Windows.Controls.TextBox control named tbFocusMe
[!code-xamlTextBox_MiscCode#_TextBoxFocusXAML]
Example
The following example calls the xref:System.Windows.UIElement.Focus%2A method to set the focus on the xref:System.Windows.Controls.TextBox control with the Name tbFocusMe.
[!code-csharpTextBox_MiscCode#_FocusTextBox] [!code-vbTextBox_MiscCode#_FocusTextBox]
See Also
xref:System.Windows.UIElement.Focusable%2A
xref:System.Windows.UIElement.IsFocused%2A
TextBox Overview
RichTextBox Overview