troubleshooting Question

Sorting a databound DataGridView column containing feet and inch values?

Avatar of JasonWilliam
JasonWilliam asked on
.NET ProgrammingVisual Basic.NET
8 Comments1 Solution2808 ViewsLast Modified:
Ok, this has got me stumped.  How do I sort a column in a databound DataGridView, that has string values that represent feet and inches?  For example,

SortMe
0' 10"
1' 9"
 2' 4"
4' 5"

Here is some sample code to play with:  add a DataGridView to your main form, add a single column to it, with 'Name' and 'DataPropertyName'  = "SortMe"

    Private Function CreateMyDataSource() As DataTable
        Dim retList As New DataTable

        retList.Columns.Add("SortMe")
        For i As Integer = 0 To 20
            Dim dr As DataRow = retList.NewRow
            dr.Item("SortMe") = i & "' " & i Mod 12 & Chr(34)
            retList.Rows.Add(dr)
        Next
        Return retList
    End Function

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        DataGridView1.AutoGenerateColumns = False
        DataGridView1.DataSource = CreateMyDataSource()
        Application.DoEvents()
    End Sub
ASKER CERTIFIED SOLUTION
PaulHews

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros