Click here to Skip to main content
15,893,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an unbound DataGridView w/ multiple columns(10). I add data to it programatically when a button is clicked. The first column contains durations in milliseconds(1000 = 1sec). Each time a row of data is added to the dataGridView, I need it to update the sort list of the rows depending on the value of column1(ms).
I'm using DataGridView1.listSortDirection(ascending), but it sorts them as strings instead of integers, when I need them to be sorted from least(top) to greatest(bottom). Someone mentioned setting the column's dataValueType, but I'm a novice at programming, and have no idea how to do this. Any help would be greatly appreciated.
Posted

Please see this post
How to sort a DataGridView Column numerically?[^]
I think it may be helpful.
 
Share this answer
 
Comments
7774tlas 18-Apr-12 22:41pm    
Sorry for the confusion, but I'm the one who posted that original question. I was having some login problems, and was unable to comment, So I created a new account and asked again. The webmaster got it fixed though, and I posted a reply on that post.
DataValueType is correct - check the type of the field that contains millisecond.
If the type is string sorting would be based on strings.
If the type is numeric, the sort would be based on numbers.
 
Share this answer
 
Comments
7774tlas 15-May-12 21:11pm    
OK, I changed the value Type to numeric, but I'm still getting the same results. I changed the DataValueType in the DataGridView Properties, is this the correct method, or do I need to do it in code?

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