Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15475

VS 2017 Correctly Sort Date Values in DataGridView

$
0
0
Hello:

I have a DataGridView with columns, that if double clicked can be sorted.

I am using Typed DataSets.

Below is a partial example of code:
Code:

        Dim ta_JobInfo As JobSheetDataSetTableAdapters.JobInfoTableAdapter = New JobSheetDataSetTableAdapters.JobInfoTableAdapter
        ta_JobInfo.Fill(JobSheetDataSet1.JobInfo)

        Dim row_JobInfo_read As JobSheetDataSet.JobInfoRow = JobSheetDataSet1.JobInfo.FindByJobNo(_JobNo)
        With row_JobInfo_read
            JobNo = .JobNo
            Product = .Product
            Detail = .Detail
            DRAWINGNO = .DrawingNo
            Started = .Started ' Date
            Completed = .Completed ' Date
            Engineer = .Engineer
            Designer = .Designer
            Checker = .Checker
            EstHrs = CStr(.EstHrs) ' Decimal
            ShipTo = .ShipTo
            ShipDate = .ShipDate ' Date
            FMLDrawingNo = .FMLDrawingNo

        End With

The result is some date columns. Yet when I click to sort them, they are sorted not by the date, but by their value. Both the database and the .NET variables are Date fields.

ie:
Code:

Dim Started As Date
        Dim Completed As Date
        Dim ShipDate As Date

The illustration below is what happens when I double click the ShipDate column in the DataGridView. You can see that it is not sorted by date but by the string value.

Name:  2021-07-26 13_42_17-Form2.bmp
Views: 32
Size:  92.1 KB


How can I make this work?
Attached Images
 

Viewing all articles
Browse latest Browse all 15475

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>