Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this column named 'quantity' and I use these codes to sort that column.

VB
dgFast.Sort(dgFast.Columns(1), System.ComponentModel.ListSortDirection.Descending)
dgSlow.Sort(dgSlow.Columns(1), System.ComponentModel.ListSortDirection.Ascending)


It sorts but about 3 rows from the top and the remaining sort by themselves.

9
8
7
25
15
14
Posted
Comments
PIEBALDconsult 15-Sep-14 14:04pm    
It looks like they're being sorted as strings rather than as numbers. Ensure that the table contains numeric data.
Doughnatch 15-Sep-14 14:43pm    
I've tried to convert it to integer with:

dgcol.columns(1).valuetype = getType(Integer)

but still it sorts incorrectly.

1 solution

You can specify sorting criteria explicitly. Please see this CodeProject question: How to sort a DataGridView Column numerically?[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900