You need to do a search on the text with a mark of all the words found. The problem is that the first word is marked, then if there is one more coincidence in the text, then the found word is not found but the next word.
if (textBox2.Text == "") MessageBox.Show("Введите текст"); else { string[] words = stroka.Split(new Char[] { ',', ' ', '\n' }); int index = stroka.IndexOf(textBox2.Text); for (int i = 0; i < words.Length; i++) { MessageBox.Show(words[i]); if (words[i] == textBox2.Text) { MessageBox.Show("Индекс входа " + index.ToString()); richTextBox1.SelectionStart = index; richTextBox1.SelectionLength = textBox2.TextLength; richTextBox1.SelectionColor = Color.Green; MessageBox.Show("Количество символов " + (richTextBox1.SelectionLength).ToString()); index = richTextBox1.SelectionLength + 1; } } } return stroka; I can not understand how to write, so that it takes the initial index not from the next word, but from the next match.
