Пример #1
0
        private void findWord()
        {
            _FindDialog  hpl      = new _FindDialog();
            DialogResult hpl_data = hpl.ShowDialog(this);

            if (hpl_data == DialogResult.OK)
            {
                if (hpl.searchTerm.Length > 0)
                {
                    dashboard.findLength = hpl.searchTerm.Length;
                    int startIndex = 0;
                    while (startIndex < dashboard.richTextBox1.TextLength)
                    {
                        int wordStartIndex = dashboard.richTextBox1.Find(hpl.searchTerm, startIndex, RichTextBoxFinds.None);
                        if (wordStartIndex != -1)
                        {
                            dashboard.richTextBox1.SelectionStart     = wordStartIndex;
                            dashboard.richTextBox1.SelectionLength    = hpl.searchTerm.Length;
                            dashboard.richTextBox1.SelectionBackColor = Color.Yellow;
                            dashboard.findPosition.Add(wordStartIndex);
                        }
                        else
                        {
                            break;
                        }
                        startIndex += wordStartIndex + hpl.searchTerm.Length;
                    }
                }
            }
        }
Пример #2
0
        private void ToolStripButton16_Click(object sender, EventArgs e)
        {
            _FindDialog  hpl      = new _FindDialog();
            DialogResult hpl_data = hpl.ShowDialog(this);

            if (hpl_data == DialogResult.OK)
            {
                if (hpl.searchTerm.Length > 0)
                {
                    this.findLength = hpl.searchTerm.Length;
                    int startIndex = 0;
                    while (startIndex < this.richTextBox1.TextLength)
                    {
                        int wordStartIndex = this.richTextBox1.Find(hpl.searchTerm, startIndex, RichTextBoxFinds.None);
                        if (wordStartIndex != -1)
                        {
                            this.richTextBox1.SelectionStart     = wordStartIndex;
                            this.richTextBox1.SelectionLength    = hpl.searchTerm.Length;
                            this.richTextBox1.SelectionBackColor = Color.Yellow;
                            this.findPosition.Add(wordStartIndex);
                        }
                        else
                        {
                            break;
                        }
                        startIndex += wordStartIndex + hpl.searchTerm.Length;
                    }
                }
            }
        }