OS : Windows 7
IDE : Microsoft Visual Studio Professional 2012
Microsoft .NET Framework 4.5.51209
DeploymentTool : DevExpress 14.1
Form : WinForm
IDE : Microsoft Visual Studio Professional 2012
Microsoft .NET Framework 4.5.51209
DeploymentTool : DevExpress 14.1
Form : WinForm
| Date | Time |
|---|---|
| 20150223 | 114322 |
| 20150211 | 212907 |
| 20150212 | 202059 |
I want to change column format string to datetime.
then, What should I do?
I finally got it.
this.gridView1.CustomColumnDisplayText += (sneder, e) =>
{
if (e.Column.FieldName.Equals("Date"))
{
if (e.Value != null && e.Value.ToString() != "")
{
string strPattern = "yyyyMMdd";
DateTime dtDate;
if (DateTime.TryParseExact(e.Value.ToString(), strPattern, null, System.Globalization.DateTimeStyles.None, out dtDate))
e.DisplayText = string.Format("{0:yyyy-MM-dd}", dtDate);
}
}
if (e.Column.FieldName.Equals("Time"))
{
if (e.Value != null && e.Value.ToString() != "")
{
string strPattern = "hhmmss";
TimeSpan dtTime;
if (TimeSpan.TryParseExact(e.Value.ToString(), strPattern, null, System.Globalization.TimeSpanStyles.None, out dtTime))
e.DisplayText = string.Format("{0}", dtTime);
}
}
};
| Date | Time |
|---|---|
| 2015-02-23 | 11:43:22 |
| 2015-02-11 | 21:29:07 |
| 2015-02-12 | 20:20:59 |
댓글 없음:
댓글 쓰기