实现效果:

知识运用:
RichTextBox控件的SelectedText属性
实现代码:
private void button1_Click(object sender, EventArgs e)
{
if (richTextBox1.SelectedText.ToString()!= "")
{
richTextBox1.SelectedText = textBox1.Text;
}
else { MessageBox.Show("请选择要替换的文字"); }
}
原文:https://www.cnblogs.com/feiyucha/p/10158931.html