if you want to search a key in a text box you can do like this:
private void FindForText(string key, int startIndex)
{
int index = this.TextBox.Text.IndexOf(key, startIndex);
if (index == -1)
{
this.EditFindNext.Enabled = false;
MessageBox.Show("Match not found!",
"Find",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
this.EditFindNext.Enabled = true;
this.TextBox.SelectionStart = index;
this.TextBox.SelectionLength = key.Length;
this.TextBox.ScrollToCaret();
}