public void Search() { string text = ""; int index; text = richTextBox1.Text.Substring(selected_index + keyword.Length); index = text.IndexOf(keyword); if (index != -1) { richTextBox1.Focus(); richTextBox1.Select(selected_index + keyword.Length + index, keyword.Length); selected_index += index + keyword.Length; } else { if (selected_index == -keyword.Length) { MessageBox.Show("No such keyword \"" + keyword + "\"in this file", "Error"); keyword = ""; Lab1_8_Form_2 f2 = new Lab1_8_Form_2(); f2.f1 = this; f2.Show(); } else { selected_index = -keyword.Length; Search(); } } }
private void Button3_Click(object sender, EventArgs e) { if (keyword == "") { Lab1_8_Form_2 f2 = new Lab1_8_Form_2(); f2.f1 = this; f2.Show(); } else { Search(); } }