如何在DataGridview中对DateTime列进行排序 [英] How to Sort the DateTime Column in DataGridview

查看:134
本文介绍了如何在DataGridview中对DateTime列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在这些要求上花的更多,但是我没有得到答案。



我有一个包含BENCHMARKNO,BENCHMARKNAME等列的DataGrid,客户编码,NOFILES,REFERENCENO,NORESOURCES,STARTDATE,FINISHDATE,AUTHORIZEDBY。





除了STARTDATE和FINISHDATE列之外,剩余的所有列都已成功排序。





我得到这样的日期格式





01-March-2010



05-February-2009



13- 2009年1月



07-July-2013





我想要喜欢这些:



13-January-2009

05-February-2009



01-March-2010



07-July-2013





请任何人帮助我。

Hi Guys , i was spent more on these requirement, but i doesn't get the answer.

I Have a DataGrid with columns Like BENCHMARKNO ,BENCHMARKNAME ,CLIENTCODE ,NOFILES ,REFERENCENO ,NORESOURCES ,STARTDATE, FINISHDATE, AUTHORIZEDBY.


Except STARTDATE and FINISHDATE Columns , Remaining all columns are sorted successfully.


I am getting the Date Formats like these


01-March-2010

05-February-2009

13-January-2009

07-July-2013


I Want like these :

13-January-2009
05-February-2009

01-March-2010

07-July-2013


Please any one help me.

推荐答案

我不确定你要求的是什么...



您可以使用DataGridView属性对2种方法中的数据进行排序:

1):在WinForms DataGridView控件中对数据进行排序 [ ^ ]



2)排序i ts datasource:

I'm not sure what about you're asking for...

You can sort data in 2 methods:
1) using DataGridView properties: Sorting Data in WinForms DataGridView Control[^]
or
2) sorting its datasource:
SELECT Field1, Field2, ...
FROM YourDataBase
ORDER BY StartDate, EndDate





日期格式与它无关。



Date format has nothing to do with it.


我做了很多寻找然后使用真的很容易。我添加了一个隐藏列,并按以下格式输入字符串日期:

File.GetLastWriteTime(fl).ToString(" yyyyMMddhhmm")并对隐藏列进行排序。

当我使用文件时间时,没有理由说任何日期/时间都不起作用。
I did a lot of looking and then used something really easy. I added a hidden column, and put in a string date in the following format:
File.GetLastWriteTime(fl).ToString("yyyyMMddhhmm") and sorted the hidden column.
While I am using a file time there is no reason that any date/time should not work.


这篇关于如何在DataGridview中对DateTime列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆