I have a textbox and two events. The first event selects all text in the textbox if there is any. The second event deselects the text.
My to events...
private void Textbox_enter( object s, EventArgs e )
{
TextBox box = s as TextBox;
box.SelectionStart = 0;
box.SelectionLength = box.Text.Length;
box.HideSelection = false;
}
private void Textbox_leave( object s, EventArgs e )
{
TextBox box = s as TextBox;
box.HideSelection = true;
}
this works fine when i use my mouse to enter and leave the textbox. Once entered I can not TAB out of that Textbox.
The code below has the same result...
private void Textbox_enter( object s, EventArgs e )
{
TextBox box = s as TextBox;
box.SelectAll();
box.HideSelection = false;
}
private void Textbox_leave( object s, EventArgs e )
{
TextBox box = s as TextBox;
box.DeselectAll();
box.HideSelection = true;
}
Please help me to solve this the correct way.