Israel

Israel

  • NA
  • 1.3k
  • 203.1k

Its doenst clean my textbox? What happen?

Dec 5 2014 3:30 PM
Hi!


I write this code to start always with a capital letter in my textbox. its works!
But what happen? When I click on my button to clean my textbox (or combobox). I receive this message: Index was outside the bounds of the array. What happen?

Code to have the first capital letter:

 private void txtdesignation_TextChanged(object sender, EventArgs e)
        {
            char[] v = txtdesignation.Text.ToCharArray();
            string s = v[0].ToString().ToUpper();
            for (int b = 1; b < v.Length; b++)
                s += v[b].ToString().ToLower();
            txtdesignation.Text = s;
            txtdesignation.Select(txtdesignation.Text.Length, 0);
        }

Code to clean my textbox:
txtdesignation.Text = "";




Answers (6)