I am using SendKeys.Send("{HOME}") in a MaskedTextBox to bring the cursor to the beginning of the textbox when the text is empty.
When I try to close the project the application freezes if it doesn’t have focus.
How do I put this application in focus before I call SendKeys?
Public Class Form1
Private Sub MaskedTextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MaskedTextBox1.GotFocus
Try
SendKeys.Send("{HOME}")
Catch ex As InvalidOperationException
' Do nothing
End Try
End Sub
End Class
After that, it should give focus to the previous application and close.
{HOME} is like hitting the home key, this will not bring focus.
best thing to do to bring focus is to call the focus method on the text control. like textbox.focus();
Please include your page code, or an example of what is on the page.
MaskedTextBox1.Select(0,0)