|
-
Jan 27th, 2012, 08:59 AM
#1
Thread Starter
Addicted Member
[RESOLVED] VB.Net 2008 Sort DataGridViewTextBoxColumn Numeric values
I’m using VB.Net 2008 application program.
I’m using DataGridView, where column types DataGridViewTextBoxColumn. I have 3 fields. 1 field values are numeric, 1 field values are string and 1 field values are decimal.
When I try to sort the string value column, it sorts correctly. But when i try to sort the numeric value column, it sorts as if its string value.
I searched a lot to make it sort numerically. But I couldn’t find it.
If you know how i can sort that column, please help me. If you can provide an example, that will be so helpful.
Thanks in advance.
-
Jan 27th, 2012, 11:33 AM
#2
Junior Member
Re: VB.Net 2008 Sort DataGridViewTextBoxColumn Numeric values
Have you defined the column as int32?
-
Jan 27th, 2012, 11:39 PM
#3
Re: VB.Net 2008 Sort DataGridViewTextBoxColumn Numeric values
i tried to recreate your problem...
as Skilleddreamer said, you must be adding the numeric (integer?) values as strings.
here's the code i used to add some rows to my dgv, which sorts correctly:
vb Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strings() As String = {"one", "two", "three", "four", "five"}
For x As Integer = 1 To 50
DataGridView1.Rows.Add(x, strings((x - 1) Mod 5), CDec(x + 0.5))
Next
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 29th, 2012, 07:58 AM
#4
Thread Starter
Addicted Member
Re: VB.Net 2008 Sort DataGridViewTextBoxColumn Numeric values
Thanks Skilleddreamer and Paul for your help. it's working.
As you mentioned while adding data to column, somehow i converted that to string. once i removed that, it's working fine and start sorting.
Thanks a lot for your help...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|