void HighlightText() { //if (String.IsNullOrEmpty(Text1RichTextBox.Text)) //{ // return; //} //int start = 0; //int end = Text1RichTextBox.Text.LastIndexOf("hoppade"); Text1RichTextBox.SelectAll(); Text1RichTextBox.SelectionBackColor = Color.Transparent; //Text1RichTextBox.Find("hoppade", 0, Text1RichTextBox.TextLength, RichTextBoxFinds.MatchCase); //Text1RichTextBox.Select(5, 10); //Text1RichTextBox.SelectionBackColor = Color.Yellow; Text1RichTextBox.Select(1, 27 - 20); Text1RichTextBox.SelectionBackColor = Color.Yellow; //start = Text1RichTextBox.Text.IndexOf("hoppade", start) + 1; }
void MatchString(string text1, string text2) { char[] textChar1 = text1.ToCharArray(); List <char> listFirstText = textChar1.OfType <char>().ToList(); char[] textChar2 = text2.ToCharArray(); List <char> listSecondText = textChar2.OfType <char>().ToList(); int count = 0; foreach (char letter in listFirstText) { if (letter != listSecondText[count]) { //Text2RichTextBox.Select(count, count); //Text2RichTextBox.SelectionBackColor = Color.Yellow; if (selectFirst == null) { selectFirst = count; } else { selectLast = count; } listSecondText.RemoveAt(count); } count++; } Text1RichTextBox.Select((int)selectFirst, (int)selectLast); Text1RichTextBox.SelectionBackColor = Color.Yellow; //int count = 0; //foreach(char array in textChar1) //{ // if(array != textChar2[count]) // { // //Text1RichTextBox.Text += Environment.NewLine + array.ToString(); // Text2RichTextBox.Select(count, count); // Text2RichTextBox.SelectionBackColor = Color.Yellow; // } // count++; //} }