我正在创建一个RTF编辑器,我需要有关搜索功能的帮助。我已经创建了查找和替换代码,但我无法弄清楚如何编写find next
和replace all
代码。任何帮助都感激不尽。以下是我已经拥有的代码。 (我正在使用Visual Studio 2010 c#)
private void buttonFind_Click(object sender, EventArgs e)
{
RichTextBox frm1TB = ((Form1)this.Owner).rTB;
int foundAt;
foundAt = frm1TB.Text.IndexOf(txtSearch.Text);
if (foundAt == -1)
{
MessageBox.Show("Not Found");
}
else
{
frm1TB.SelectionStart = foundAt;
frm1TB.SelectionLength = txtSearch.TextLength;
frm1TB.Focus();
btnFindnext.Enabled = true;
btnReplaceall.Enabled = true;
btnReplace.Enabled = true;
}
}
private void buttonfindNext_Click(object sender, EventArgs e)
{
}
private void buttonreplace_Click(object sender, EventArgs e)
{
RichTextBox frm1TB = ((Form1)this.Owner).rTB;
btnFind_Click(sender,e);
frm1TB.SelectedText = txtReplace.Text;
}
private void buttonreplaceAll_Click(object sender, EventArgs e)
{
}