Q:

unable to clear a textbox data

I'm not able to delete textbox data with the code below   
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {            
        if(char.IsDigit(e.KeyChar)==false)
        {
            count++;
       }
        if (count == 1)
        {
            textBox1.Text = ("");
            count = 0;
        }
   }

tried using clear method as well the alphabet i entered stays in the textbox and when i type any key it get overwritten but i want the textbox to be empty the second time and the prev data to be removed 

A:

you just need to say you've handled the event:
    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (char.IsDigit(e.KeyChar) == false)
        {
            count++;
        }
        if (count == 1)
        {
            textBox1.Text = ("");
            count = 0;
            e.Handled = true; // this bit fixes it
        }
    }

