Solved

Add 'Find' Functionality to Forms App

Posted on 2009-07-01
1
224 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

3 Use Cases for Connected Systems

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

Question has a verified solution.

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

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…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

22 Experts available now in Live!

Get 1:1 Help Now