Solved

Add 'Find' Functionality to Forms App

Posted on 2009-07-01
1
223 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Contant UI messages in .NET 1 40
Copy Data from one datatable to another datatable. 8 53
Problem to Popup 2 48
Code enhancement 5 12
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now