Jump and mark row when typing in datagridview (like you can do in a listbox)

I want to be able to click into a datagridview and based on one of the columns (productname), and then for example type letter "D" or maybe "DE", and then jump to the first row that contains "D" or "DE".

In a Listbox this works without no extra code, how to do this in a DataGridview in VB.NET?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Hi.. thorv71

As far as i know
there is no such a property (option) for datagridview..
Usually for DGV we use the BindingSource.Filter method or the DataView RowFilter in accordance with TextChange Event of a TextBox..
If something like this reaches your needs please ask further to provide you some code...

Maybe there is a way to achieve that but i think you might override the standard DGV or write some extra code

thorv71Author Commented:
I don't want to use a textbox, because her it is four DGVs side by side, and where the first DGVs choice filter the second and then so.. for the third an fourth.

So if i go to the second DGV and type "DE" the result for the DGV has to stay the same, "all" I want is that the the DGV jump and select the first row that start with f.ex "DE" if it exists in the row.

Some one that has some code snip for this ?  :-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

thorv71Author Commented:
The Code in the article was a little bit to complex for me, I resolved this with a less code. Only this code just allows me to use one letter, so if you know how I can retrive more then one letter using e.KeyChar or something like that, I will be very pleased :-)

This is my Simple Code:  :-)

        Dim i As Integer
        Dim keypresset As String = ""
        Dim prg_navn As String = ""
        Dim prg_navn_first_letter As String = ""
        keypresset = e.KeyChar

        For Each RW As DataGridViewRow In Me.DataGridView_PRG.Rows

            i = RW.Index
            prg_navn = RW.Cells("prg_navn").Value.ToString
            prg_navn_first_letter = Mid(prg_navn, 1, 1)

            If keypresset = LCase(prg_navn_first_letter) Then
                Me.DataGridView_PRG.Rows(i).Selected = True
                Me.DataGridView_PRG.CurrentCell = DataGridView_PRG.Rows(i).Cells("prg_navn")
                Exit For
            End If
What event are you handling for this code, which is generating the e.KeyChar property? KeyChar is only going to get one letter, but you can potentially combine additional letters. You'd need to define the match string at the class rather than method level (so it survives multiple calls). It would need to be blanked out when the form displays, or when entering the DataGridView.

Or you could just use the code in the article. You'd only need to alter the Load event handler with your DGV name, etc. So what if it has some stuff you don't understand? As long as it does what you want, there's really no reason to fear. I've gotten code segments from here and elsewhere on the Web, and frankly I don't understand how all of them work, but work they do. But I understand if you want to use a more standardized approach.
thorv71Author Commented:
The case is that I need to use this code in a solution where it is over 25 DGVs, and I dont like to use more code than nesseary to do this event, and I like to understand the code 100% i case of problem in the future.

I have talk to me customer now, and they just need to use the first letter, so the code that I wrote works, but thanks for any help anyway :-)
I would have been happy to talk you through the code, but if you're all set with what you have, that's your choice. Thanks for the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.