示例#1
0
        void form_FindClick(object sender, FindEventArgs e)
        {
            int index = TextBoxHelper.Find(GetActiveTextBox, e.template, e.matchCase, e.searchDown);

            if (index < 0)
            {
                GetActiveTextBox.Select(GetActiveTextBox.Text.Length, 0);
                MessageBox.Show((Form)sender, "Can't find " + "\"" + e.template + "\"", "TextEditor", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                GetActiveTextBox.Select(index, e.template.Length);
            }
        }
示例#2
0
        public static void ReplaceAll(RichTextBoxPrintCtrl.RichTextBoxPrint e, string template, string newTemplate, bool matchCase)
        {
            int index = 0;

            e.SelectionStart = index;
            RichTextBoxFinds caseComparison = matchCase ? RichTextBoxFinds.MatchCase : RichTextBoxFinds.None;

            while (index != -1)
            {
                index = TextBoxHelper.Find(e, template, matchCase, true);
                if (index != -1)
                {
                    e.Select(index, template.Length);
                    TextBoxHelper.Replace(e, template, newTemplate, matchCase);
                }
            }
            e.SelectionLength = 0;
            e.SelectionStart  = 0;
        }