在RichTextBox控件中替换文本文字

时间:2023-03-09 19:36:32
在RichTextBox控件中替换文本文字

实现效果:

  在RichTextBox控件中替换文本文字

知识运用:

  RichTextBox控件的SelectedText属性

实现代码:

        private void button1_Click(object sender, EventArgs e)
{
if (richTextBox1.SelectedText.ToString()!= "")
{
richTextBox1.SelectedText = textBox1.Text;
}
else { MessageBox.Show("请选择要替换的文字"); }
}

相关文章