How to erase the last character of a textBox after a certain length in c #?

I'm trying to erase the characters that are typed in a textBox after its length is equal to 10, but when this condition is met these new characters replace the first letters of the text. example
1234567890 -If I type 5 another number this will replace the, like this:
5234567890

code:

private void materialSingleLineTextField2_KeyPress (object sender, KeyPressEventArgs e)
    {

       if (txtName.Text.Length> 10)
        {
            String text = txtName.Text;
            text = text.Substring (0, text.Count () - 1);
            txtName.Text = text;

        }
    }