MBHEY131
asked on
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
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
It will have to be a custom sort
Example here
https://msdn.microsoft.com/en-us/library/ms171608%28VS.80%29.aspx
Example here
https://msdn.microsoft.com/en-us/library/ms171608%28VS.80%29.aspx
ASKER
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??
ASKER
OK moving along now - the code "cform.CustomersBindingSou rce.MoveNe xt()" 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:
the only thing I added was the "cform.CustomersBindingSou rce.MoveNe xt()" line ??
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
the only thing I added was the "cform.CustomersBindingSou
Use FirstDisplayedScrollingRow Index property
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.firstdisplayedscrollingrowindex(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.firstdisplayedscrollingrowindex(v=vs.110).aspx
ASKER
could you give me an example and tell me where to insert the example in the code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER