2015년 2월 23일 월요일

Xtragrid column format change : string to datetime

OS : Windows 7
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

댓글 없음:

댓글 쓰기

대항해시대 조선 랭작

숙련도 획득 방법 선박 건조, 선박 강화, 전용함 추가시 숙련도 획득 모두 동일한 공식 적용 획득 숙련도 공식 기본 획득 숙련도 ≒ int{건조일수 × 현재랭크 × (0.525)} 이벤트 & 아이템 사용...