コード例 #1
0
        // Search
        private void Search_In_Script()
        {
            int index       = -1;
            int selectStart = Script_richTextBox.SelectionStart;  // The Index of the Typer


            // Reset Back Color
            Script_richTextBox.SelectAll();
            Script_richTextBox.SelectionBackColor = Script_richTextBox.BackColor;
            Script_richTextBox.Select(selectStart, 0);


            // Search
            if (Search_Script_textBox.Text.Length > 0) // IF SearxhTexbox is not empty
            {
                while ((index = Script_richTextBox.Text.IndexOf(Search_Script_textBox.Text, (index + 1), StringComparison.OrdinalIgnoreCase)) != -1)
                {
                    Script_richTextBox.Select((index), Search_Script_textBox.Text.Length); // Select the word
                    Script_richTextBox.SelectionBackColor = Color.FromArgb(196, 49, 86);   // Change color of the Selected Word
                    Script_richTextBox.Select(selectStart, 0);                             // Selecteion start is the Typers last position before i began to select word
                    Script_richTextBox.SelectionBackColor = Script_richTextBox.BackColor;  // Reset Fore Color
                    Script_richTextBox.ScrollToCaret();                                    // Scroll To Word
                }
            }
        }