Datagredview row selection sortmode

My datagridview is: "DATAGRIDVIEW1" which has several Columns, but the columns in question are "LastName" and "VIN"

And I have several chunks of code that Gets me to letting customers enter FIND DATA and the code does take them to the correct row within the "DATAGRIDVIEW1"  but after that I would like to REORDER MY "ROWS ONLY" TO REFLECT THE DATA THEY HAVE INPUT???

e.g.

If they select "LASTNAME" and  enter "SMITH"  I would like to reorder and show all the "SMITH'S" UNDER the row that they have selected.

Could anyone help me with the code
MBHEY131Asked:
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.

MBHEY131Author Commented:
vb.net and vs2012
0
CodeCruiserCommented:
It will have to be a custom sort

Example here

https://msdn.microsoft.com/en-us/library/ms171608%28VS.80%29.aspx
0
MBHEY131Author Commented:
ok - I've got the sort problem fixed - here is my next trouble - once I have gotten to the correct row and sorted correctly the Selected Row is not visible on the screen unless you use the sidebar and go and find it - not a huge issue but I would like the system to bring the selected row to the visible screen??? Could you help with that code??
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MBHEY131Author Commented:
OK moving along now - the code "cform.CustomersBindingSource.MoveNext()" solved the datagridview1 to move to the selected row on the screen correctly, however somehow now we are getting an extra row selected for some reason:
Here's the code:
       cform.DataGridView1.AllowUserToAddRows = False
        For Each row As DataGridViewRow In cform.DataGridView1.Rows
            cform.CustomersBindingSource.MoveNext()
            If cform.DataGridView1.Rows(intcount).Cells(CellToLookIn).Value.ToString = CustText Then
                cform.DataGridView1.Rows(intcount).Selected = True
                FindCust = True
                Exit Function
            End If
            intcount = intcount + 1
        Next
        cform.DataGridView1.AllowUserToAddRows = True
 

Open in new window


the only thing I added was the "cform.CustomersBindingSource.MoveNext()" line ??
0
MBHEY131Author Commented:
could you give me an example and tell me where to insert the example in the code?
0
CodeCruiserCommented:
At the end of the sort, just set the firstdisplayedscrollingrowindex to the index of the selected row.
0

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
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.