private static void TrimSelectedText(TextBox textBox) { if (textBox.SelectionLength > 0) textBox.Text = textBox.Text.Remove(textBox.SelectionStart, textBox.SelectionLength); }