Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Add 'Find' Functionality to Forms App

Posted on 2009-07-01
1
226 Views
Last Modified: 2013-12-17
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?
0
Comment
Question by:thegreekitalian
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24758404
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;
                textBox1.Focus();
            }
            else
                MessageBox.Show(value, "Not Found");
        }

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question