Select all text in a TextBox on mouse click: TextBox.Focus(); TextBox.SelectAll();

I am trying to get a TextBox to highlight all of its text when clicked, but the text only stays highlighted for a fraction of a second, then the cursor appears again. I have tried using the TextBox.Enter, TextBox.MouseClick, and TextBox.GotFocus events but I have the same issue. I am using a Windows Form application.

private void TextBox_Enter(object sender, EventArgs e) {

Try using the MouseDown event instead of the Enter event:

private void TextBox_MouseDown(object sender, MouseEventArgs e) {
    TextBox textBox = (TextBox)sender;

This should highlight all the text in the TextBox and keep it highlighted even after the cursor appears.