1个回答
展开全部
//---查找基本代码-------------------------
string Searchstr;
int index=-1, searchStart=0;
Searchstr="要查询的";
index=richTextBox1.Find(Searchstr,searchStart,RichTextBoxFinds.MatchCase);
if(index>=0)
{
richTextBox1.SelectionStart=index;
richTextBox1.SelectionLength=Searchstr.Length;
searchStart=index+1;
}
//---替换基本代码-------------------------
string Searchstr;
int index, searchStart=0;
Searchstr="要替换的";
while(true)
{
index=richTextBox1.Find(Searchstr,searchStart,RichTextBoxFinds.MatchCase);
if(index>=0)
{
richTextBox1.SelectionStart=index;
richTextBox1.SelectionLength=Searchstr.Length;
richTextBox1.SelectedText="要替换的";
searchStart=index+Searchstr.Length+1;
}
else
break;
}
差不多这个样子
string Searchstr;
int index=-1, searchStart=0;
Searchstr="要查询的";
index=richTextBox1.Find(Searchstr,searchStart,RichTextBoxFinds.MatchCase);
if(index>=0)
{
richTextBox1.SelectionStart=index;
richTextBox1.SelectionLength=Searchstr.Length;
searchStart=index+1;
}
//---替换基本代码-------------------------
string Searchstr;
int index, searchStart=0;
Searchstr="要替换的";
while(true)
{
index=richTextBox1.Find(Searchstr,searchStart,RichTextBoxFinds.MatchCase);
if(index>=0)
{
richTextBox1.SelectionStart=index;
richTextBox1.SelectionLength=Searchstr.Length;
richTextBox1.SelectedText="要替换的";
searchStart=index+Searchstr.Length+1;
}
else
break;
}
差不多这个样子
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询