Beispiel #1
0
        //find and replace tool element
        private void ReplaceNowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String FindFor     = FindForReplaceTB.Text;
            int    FoundAt     = RTBFileReader.Text.IndexOf(FindFor);
            String ReplaceWith = ReplaceWithTB.Text;
            String PullText    = RTBFileReader.Text;

            if (FindForReplaceTB.Text != String.Empty && PullText.Contains(FindFor))
            {
                String ReplacedText = PullText.Replace(FindFor, ReplaceWith);
                RTBFileReader.Text = ReplacedText;
                RTBFileReader.Focus();
            }
            if (FindForReplaceTB.Text == String.Empty)
            {
                MessageBox.Show("You must enter some text to be replaced.");
            }
            if (ReplaceWithTB.Text == String.Empty && FoundAt >= 0)
            {
                MessageBox.Show("You must enter some new text.");
            }
            if (FindForReplaceTB.Text != String.Empty && FoundAt < 0)
            {
                MessageBox.Show("Text not found in document. \nFind and Replace function is case sensitive.");
            }
        }
Beispiel #2
0
        //find tool element
        private void FindTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String FindIn  = TBFindMenuBox.Text;
            int    FoundAt = RTBFileReader.Text.IndexOf(FindIn);

            if (TBFindMenuBox.Text != String.Empty && FoundAt >= 0)
            {
                RTBFileReader.Focus();
                RTBFileReader.Select(FoundAt, 0);
            }
            if (TBFindMenuBox.Text == String.Empty)
            {
                MessageBox.Show("You must enter some text to be found.");
            }
            if (TBFindMenuBox.Text != String.Empty && FoundAt < 0)
            {
                MessageBox.Show("Text not found in document. \nFind function is case sensitive.");
            }
        }