textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart-1,1); 当退到头的时候程序就报错了~各位大大们 求帮忙~

解决方案 »

  1.   

    加判断
    if(textBox1.Text.ToString().Trim().Length>0)
    {}
      

  2.   


    if(textBox1.Text.ToString().Trim().Length>0)
    {
       textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart-1,1);
    }
      

  3.   

    if(String.IsNullOrEmpty(TextBox1.Text))
    {
    return;
    }
    else
    {
    //执行你上面的代码;
    }
      

  4.   

    if (textBox1.Text.Length > 0)
      {
      textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
      }