rt

解决方案 »

  1.   

    richTextBox2.Text="\\\\"+richTextBox1.SelectedText.Replace("\n","\n\\\\");
    在.net2003中执行通过
      

  2.   

    如果替换原来的话再加一句
    richTextBox1.Text=richTextBox1.Text.Replace(richTextBox1.SelectedText,richTextBox2.Text);
      

  3.   

    我已解决,如下:
    int beginIndex = this.txt.GetLineFromCharIndex(this.txt.SelectionStart);
    int lastIndex = this.txt.GetLineFromCharIndex(this.txt.SelectionStart + this.txt.SelectionLength);string newStr = String.Empty;
    string oldStr = this.txt.SelectedText;
    if (oldStr == String.Empty)
    oldStr = this.txt.Lines[beginIndex];for (int i = beginIndex; i <= lastIndex; i ++)
    {
    if (i != lastIndex)
    newStr += "//" + this.txt.Lines[i] + "\r\n";
    else
    newStr += "//" + this.txt.Lines[i];
    }
    this.txt.Text = this.txt.Text.Replace(oldStr, newStr);