I have been trying to sort a column in DataGridView (vb.net) and as far as it is considered as string, can not be sorted properly. it shows something like this : 1 1 1 10 2 2 26 3 ...
any suggestion ?
I have been trying to sort a column in DataGridView (vb.net) and as far as it is considered as string, can not be sorted properly. it shows something like this : 1 1 1 10 2 2 26 3 ...
any suggestion ?
The default type of DataGridView Cells is String. But if you set a different type in the DataSource, the corresponding cells would behave accordingly. Sample code:
Dim dt As DataTable = New DataTable
dt.Columns.Add("col1", GetType(Integer))
dt.Rows.Add(1)
dt.Rows.Add(10)
dt.Rows.Add(2)
DataGridView1.DataSource = dt
If you sort the first column of DataGridView1, it would show a numerical behaviour (e.g., 1, 2, 10 or 10, 2, 1).