By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

Datagridview not sorting data correctly

P: 1
1042
789
908
1049
after sorting


698
1042
789
908
1049
i used this code

Me.classDataGridView.Columns("Total").SortMode = True


Me.classDataGridView.Sort(Me.classDataGridView.Col umns("Total"), ListSortDirection.Descending)
Feb 11 '16 #1
Share this Question
Share on Google+
1 Reply


100+
P: 299
This is because your numbers are being entered as strings. You can always do something simple like this:

Expand|Select|Wrap|Line Numbers
  1. DataGridView1.Rows.Add(1042, 0)
  2. DataGridView1.Rows.Add(789, 0)
  3. DataGridView1.Rows.Add(908, 0)
  4. DataGridView1.Rows.Add(1049, 0)
  5. DataGridView1.Rows.Add(698, 0)
  6. DataGridView1.Sort(DataGridView1.Columns(0), System.ComponentModel.ListSortDirection.Descending)
Feb 11 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.