I am having a few problems getting a column in a datagridview to sort its items correctly in ascending order. The column contains number (File size) data so i simply want it to list the files in smallest to biggest order (Acsending order) but this doesnt work. Below is a example of the code im using for testing:
You would expect the above code to order the items in '1/2/3/4/22/51/610/6334' order when set to ascending order and reversed when in descending order. What actually happens is the items are displayed as follows:Code:DataGridView1.Columns.Add("", "Number:") DataGridView1.Rows.Add("1") DataGridView1.Rows.Add("2") DataGridView1.Rows.Add("3") DataGridView1.Rows.Add("4") DataGridView1.Rows.Add("51") DataGridView1.Rows.Add("22") DataGridView1.Rows.Add("6334") DataGridView1.Rows.Add("610") DataGridView1.Sort(DataGridView1.Columns(0), System.ComponentModel.ListSortDirection.Ascending)
1/2/22/3/4/51/610/6334
What am i doing wrong?. It appears it only sorts the numbers based on their 1st digit so any double digit or above numbers dont get sorted correctly.




Reply With Quote