I’m creating an RTF Editor and I need help with the search functions. I have already created the find and replace code but I cant figure out how to code the find next and replace all code. Any help will be much appreciated. The following is the code that I have already. ( I am using 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)
{
}
I think you can just to this: