You can use a thread to select all the text. Try this..it's a hack but it
works. You can have all your textbox Focus events use
GenericTextBox_GotFocus to handle the text selection.
private TextBox currentTB = null;
private void GenericTextBox_GotFocus(object sender, System.EventArgs e)
{
this.currentTB = (TextBox)sender;
System.Threading.Thread t = new System.Threading.Thread(new
System.Threading.ThreadStart(SelectAll));
t.Start();
}
private void SelectAll()
{
if(this.currentTB!=null)
{
//Usuall the Invoke should finish after the got focus event finishs. If
you experience problems add a sleep
//System.Threading.Thread.Sleep(50);
currentTB.Invoke(new EventHandler(InvokeSelectAll));
}
}
private void InvokeSelectAll(object sender, System.EventArgs e)
{
((TextBox)sender).SelectAll();
}