How to Call Method in C#
  • I create this method


      private void restrictAlpha(object sender, KeyPressEventArgs e)
            {
                if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
                {
                    e.Handled = true;
                }

                if (e.KeyChar == '.'
                    && (sender as TextBox).Text.IndexOf('.') > -1)
                {
                    e.Handled = true;
                }
            }


    And i have to call this method in textbox so what should i do?


    hussainroyal
  • 2 Comments sorted by
  • Vote Up0Vote Down ithackerithacker
    117.50 Karma Accepted Answer
    try

    restrictAlpha(this,e);
  • Thanks for your reply ithacker its working :)
    hussainroyal

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