Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

VS 2008 C# Substring search Intellisense

Avatar of rwheeler23
rwheeler23Flag for United States of America asked on
.NET Programming
6 Comments1 Solution382 ViewsLast Modified:
I have this snippet of code that I want to proceed to the first record matching the keys as I type them. For example:
123 would go to the first record starting with 123
123A would go to the first record starting with 123A

The problem I have is that it ignores all characters. So when I type 123A it goes to 123 and not to the record that starts with 123A. I am not looking for only digits. How do I correct this? It would also be nice if the user could backspace to correct an error. Is that possible?
private void dgvAgenciesByJobs_KeyPress(object sender, KeyPressEventArgs e)
            strSearch += e.KeyChar;
            for (i = 0; i <= dgvAgenciesByJobs.RowCount - 1; i++)
                if (dgvAgenciesByJobs[0, i].Value != null && dgvAgenciesByJobs[0, i].Value.ToString().StartsWith(strSearch))
                    dgvAgenciesByJobs.Rows[i].Selected = true;
                    dgvAgenciesByJobs.CurrentCell = dgvAgenciesByJobs[0, i];
                    if (dgvAgenciesByJobs.Rows[i].Displayed == false)
                        dgvAgenciesByJobs.FirstDisplayedScrollingRowIndex = i;

Avatar of Miguel Oz
Miguel OzFlag of Australia imageSenior Software Engineer
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers