对,我已经创建了允许用户对富文本框中的所有文本执行查找和替换的代码。但是,我现在允许用户选择要执行查找和替换的部分文本
这是我目前正在使用的代码:
Private Sub btnFFindNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFFindNext.Click
Dim length as String
length = textToFind.Text.Length
lastposition = frm1.RichTextBox.Find(textToFind.Text, lastposition, RichTextBoxFinds.None)
frm1.RichTextBox.SelectionStart = lastposition
frm1.RichTextBox.SelectionLength = length
lastposition = lastposition + 1
我还在 RTB 中添加了 form1 selection changed 事件处理程序的代码,因此当它更改时,它将当前光标位置设置为lastposition。
希望上面的代码和我的描述能帮助你理解我的情况。所以只是为了澄清,我将如何调整我的代码,以便如果用户选择一些文本,那么它只Find and Replace
对那个文本执行。一旦到达选择的末尾,它就结束了。
谢谢你。