111,089
社区成员




int 当前 = 0;
int 之前 = 0;
int 之前Length = 0;
int 位置 = 0;
private void button1_Click(object sender, EventArgs e)
{
if (this.richTextBox1.Text.Contains(this.textBox1.Text) == true)
{
richTextBox1.Focus();
当前 = this.richTextBox1.Text.IndexOf(this.textBox1.Text, 位置);
之前Length = this.textBox1.TextLength;
if (位置 != 0)
{
this.richTextBox1.SelectionStart = 之前;
this.richTextBox1.SelectionLength = 之前Length;
this.richTextBox1.SelectionColor = Color.Black;
}
this.richTextBox1.SelectionStart = 当前;
this.richTextBox1.SelectionLength = this.textBox1.TextLength;
this.richTextBox1.SelectionColor = Color.Red;
之前 = richTextBox1.SelectionStart;
位置 += 1;
}