allow only one special charactor symbol in textbox in winform
  • How to allow only one +,-,. charactor symbol in textbox

      private void textBox1_KeyPress(object sender,
    KeyPressEventArgs e)



            {



                if (textBox1.Text.Contains('.')
    && e.KeyChar == '.')



                {



                    e.Handled = true;



                }

      if (textBox1.Text.Contains('+') && e.KeyChar == '+')

                {

                    e.Handled = true;

                }

      if (textBox1.Text.Contains('-') && e.KeyChar == '-')

                {

                    e.Handled = true;

                }



            }



Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative