c#字符串替换问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 13:33:07
if (rtxtMain.SelectionStart < rtxtMain.Text.Length)
{

if (Uper.Equals(true))
{
try
{
rtxtMain.SelectedText = rep;
rtxtMain.SelectionStart = rtxtMain.Find(selec, rtxtMain.SelectionStart + rtxtMain.SelectionLength, rtxtMain.Text.Length, RichTextBoxFinds.MatchCase);

}
catch (Exception e)
{
MessageBox.Show("下文找不到" + selec + ",将从头查找!", "查找提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
rtxtMain.SelectionStart = 0;
}

}

else

ktr

你替换的不正确

你看下字符串的属性

if (rtxtMain.SelectionStart < rtxtMain.Text.Length)

应该改成:

if (rtxtMain.SelectionStart <= rtxtMain.Text.Length)

您要是觉得他们的回答都不够好就把分给我吧,谢谢了。