Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an un-bound datagrid view. It holds Names and marks obtained for students.

Marks are like 12.25, 12.35 etc.

I want to use code like
VB
dgvSM.Sort(dgvSM.Columns(2), System.ComponentModel.ListSortDirection.Descending) 


So the one with least marks comes at top. BUT it does not work.
The datagridview is being sorted based on text, not numercially.

Please help

What I have tried:

Googled alot, nothing found related
Posted
Updated 9-Jul-16 1:38am

1 solution

If the data is being sorted by a string comparison, then that because when you filled it you gave it string values.
Don't - give it double values instead and use the Column DefaultCellStyle.Format property to format the data: How to: Format Data in the Windows Forms DataGridView Control[^]
 
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