在richtextbox中,选取多行,将每行注释,即在每行前面加“//”,如何解决? rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 richTextBox2.Text="\\\\"+richTextBox1.SelectedText.Replace("\n","\n\\\\");在.net2003中执行通过 如果替换原来的话再加一句richTextBox1.Text=richTextBox1.Text.Replace(richTextBox1.SelectedText,richTextBox2.Text); 我已解决,如下: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); 怎样把数据打包用socket发送? 多线程属性累加访问,问题 FormatDateTime 问题!! 关于c#操作excel的问题 xp安装C#开发的SETUP经常出现缺少文件的提示 求正则表达式 请教大家C#中如何在一个窗体里面控制另外一窗体的控件? C#中listbox删除出现未将对象引用设置到对象实例 急急急,加急!!@牛人 flashupload上传控件360浏览器不兼容问题~~! 紧急求助:System.Windows.Forms.Timer类,为什么在Tick事件中放lock语句没有效呢?? 写了个日记软件,自己玩的,请大家指正不足之处,要源码的留下E-mail 谁有C#的基础
在.net2003中执行通过
richTextBox1.Text=richTextBox1.Text.Replace(richTextBox1.SelectedText,richTextBox2.Text);
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);