Add 'Find' Functionality to Forms App

I have a text box populated with the content of a text file.  I would like to give the user the ability to search that text box.  How can I do this?
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Something like...

        private void button1_Click(object sender, EventArgs e)
            string value = textBox2.Text;
            int index = textBox1.Text.IndexOf(value);
            if (index != -1)
                // it was found...highlight it:
                textBox1.SelectionStart = index;
                textBox1.SelectionLength = value.Length;
                MessageBox.Show(value, "Not Found");

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.