// Select all text at click event
private void TextBoxExt1_Click(object sender, EventArgs e)
{
this.textBoxExt1.SelectAll();
}
|
//unselect the text on focus
private void TextBoxExt1_GotFocus(object sender, EventArgs e)
{
this.textBoxExt1.Select(this.textBoxExt1.Text.Length, 0);
}
|
this.textBoxExt1.GotFocus += TextBoxExt1_GotFocus;
this.textBoxExt1.Click += TextBoxExt1_Click;
private void TextBoxExt1_Click(object sender, EventArgs e)
{
this.textBoxExt1.SelectAll();
this.textBoxExt1.Click -= TextBoxExt1_Click;
}
private void TextBoxExt1_GotFocus(object sender, EventArgs e)
{
this.textBoxExt1.Select(this.textBoxExt1.Text.Length, 0);
}
|
private void TextBoxExt1_GotFocus(object sender, EventArgs e)
{
focused = true;
}
bool focused = false;
private void TextBoxExt1_Click(object sender, EventArgs e)
{
if (focused)
{
this.textBoxExt1.SelectAll();
focused = false;
}
} |