datagridview按日期列排序 [英] datagridview sorting by date column
问题描述
大家好,
我目前正在为自己编写一些软件,需要指导.
我在带有日期列的表单上有一个datagridview. (column0)
我正在尝试按要发送的日期进行排序,但只会按日期(dd)进行排序,而不是按整个日期(dd/mm/yyyy)进行排序,从而使月份无法排序.
(输出示例):
#1-01/03/2012
#2-02/01/2010
#3-2011年3月2日
我需要的是按完整日期顺序排列的日期:
#1-02/01/2010
#2-2011年3月2日
#3-01/03/2012
到目前为止,我有以下代码可以对列进行排序:
Hi all,
I am currently writing a bit of software for myself and need guidance.
I have a datagridview on a form with a date column. (column0)
I am trying to sort this by date desending but it will only sort by the day (dd) and not the whole date (dd/mm/yyyy) which leaves the months unsorted.
(example of output):
#1 - 01/03/2012
#2 - 02/01/2010
#3 - 03/02/2011
what i require is the dates in complete date order:
#1 - 02/01/2010
#2 - 03/02/2011
#3 - 01/03/2012
I have the following code to sort the column so far:
AppointmentsDataGridView.Sort(AppointmentsDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Descending)
我尝试了以下引发错误的操作:
I have tried the following which throws an error:
AppointmentsDataGridView.Sort(AppointmentsDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Descending = ("dd/mm/yyyy"))
有谁有任何想法如何使它正常工作.
提前非常感谢.
Has anybody got any ideas how to get this working correctly.
Many Thanks in advance.
推荐答案
如何:在Windows窗体DataGridView控件中自定义排序 [ ^ ]
这篇关于datagridview按日期列排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!