private void biaozhu(string LX, int start, int end)
{
string str = "";
for (int i = start; i >= 0; i--)
{
str = TB1.Text.Substring(i, 1);
if (str == " " || i == 0)
{
TB1.Text = TB1.Text.Insert(i, " [ " + LX);
break;
}
}
for (int j = end; j < TB1.Text.Length; j++)
{
str = TB1.Text.Substring(j, 1);
if (str == " " || j == TB1.Text.Length )
//j == TB1.Text.Length+1
{
if (j == TB1.Text.Length) //j == TB1.Text.Length+1
{
TB1.AppendText(" ] ");
TB1.SelectionStart = j;
TB1.ScrollToCaret();//光标停留在标注的位置;
break;
}
else
{
TB1.Text = TB1.Text.Insert(j + 1, " ] ");
TB1.SelectionStart = j + 1;
TB1.ScrollToCaret();
break;
}
}
}
}
这段代码加上后怎么改,目前加括号只能加到句子的开头 |