110,571
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string find = this.textBox1.Text;
int index = this.richTextBox1.Find(find);
if (index < 0)
{
MessageBox.Show("查找不到要搜索的字符串");
return;
}
this.richTextBox1.SelectionStart = index;
this.richTextBox1.SelectionLength = find.Length;
this.richTextBox1.Focus();
}
private void button1_Click(object sender, EventArgs e)
{
if (richTextBox1.Find("as",
richTextBox1.SelectionStart + richTextBox1.SelectionLength,
richTextBox1.TextLength, RichTextBoxFinds.None) < 0) // 为-1表示没有找到
{
richTextBox1.SelectionStart = 0; // 光标设置为0位置
richTextBox1.SelectionLength = 0;
}
richTextBox1.Focus();
}