Print Page | Close Window

CXTPPropertyGridItemDate date formatting

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=9893
Printed Date: 28 April 2024 at 5:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropertyGridItemDate date formatting
Posted By: abazosan
Subject: CXTPPropertyGridItemDate date formatting
Date Posted: 14 March 2008 at 6:15am
Hi there,
 
I'm trying to change the date format of a CXTPPropertyGridItemDate item in order to set the SYSTEM date format.
 
In the docs I've just seen the method 'SetDateFormat' that gets a string argument but I don't know how to build a string  with the system date format.
 
Is there any other way to set the dateformat of the control or make it to get the system format?
 
thank you in advance,
AB.



Replies:
Posted By: mgampi
Date Posted: 14 March 2008 at 6:20am
Hi;
If you call SetDateFormat with an empty string, the format used will be the system date format:

CXRReportRecordItemDateTime* pDt=DYNAMIC_DOWNCAST(CXRReportRecordItemDateTime, AddItem(new CXRReportRecordItemDateTime(COleDateTime(dtCreated))));
pDt->SetFormatString(_T(""));
 
or you can create your own date item and use system API function to build the format strings like this:
 
IMPLEMENT_DYNAMIC(CCustomItemDateEdit, CXTPPropertyGridItemDate)
CCustomItemDateEdit::CCustomItemDateEdit(LPCTSTR strCaption, const COleDateTime& oleDate)
 : CXTPPropertyGridItemDate(strCaption, oleDate)
{
 Init();
}
CCustomItemDateEdit::CCustomItemDateEdit(UINT uiID, const COleDateTime& aDate)
 : CXTPPropertyGridItemDate(uiID, aDate)
{
 Init();
}
CCustomItemDateEdit::~CCustomItemDateEdit()
{
}
void CCustomItemDateEdit::Init()
{
 TCHAR lpIDate[2];
 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDATE, lpIDate, _countof(lpIDate));
 int iDateOrder=_ttoi(lpIDate);
 CString strFormat, strMaskFmt, strLiteralFmt; 
 if (iDateOrder==0)  // Month-Day-Year
 {
  strFormat=_T("%%m%s%%d%s%%Y");
  strMaskFmt=_T("00%s00%s0000");
  strLiteralFmt=_T("__%s__%s____");
 }
 else if (iDateOrder==1) // Day-Month-Year
 {
  strFormat=_T("%%d%s%%m%s%%Y");
  strMaskFmt=_T("00%s00%s0000");
  strLiteralFmt=_T("__%s__%s____");
 }
 else if (iDateOrder==2) // Year-Month-Day
 {
  strFormat=_T("%%Y%s%%m%s%%d");
  strMaskFmt=_T("0000%s00%s00");
  strLiteralFmt=_T("____%s__%s__");
 }
 TCHAR lpsDate[4];
 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDATE, lpsDate, _countof(lpsDate));
 m_strFormat.Format(strFormat, lpsDate, lpsDate);
 
 CString strMask, strLiteral;
 strMask.Format(strMaskFmt, lpsDate, lpsDate);
 strLiteral.Format(strLiteralFmt, lpsDate, lpsDate);
 SetMask(strMask, strLiteral);
 SetDate(GetDate());
}
CString CCustomItemDateEdit::Format(const COleDateTime& oleDate)
{
 if (oleDate.GetStatus() != COleDateTime::valid)
  return _T("");
 return oleDate.Format(VAR_DATEVALUEONLY);
}


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: abazosan
Date Posted: 17 March 2008 at 5:34am
Hi,
 
thank you for the reply;
 
I choose the first one because a quick date formatting is enough for me, and it seems to be taken the system format doing a
 
pDt->SetFormatString(_T(""));
 
but the initial date doesn't appear in the value field (it's just blank) and when I select a date from de pop up calendar, the control is not showing me the date I've just choosen. It only shows __/__/____ and nothing else.
 
Any ideas why I'm getting that?
 
thank you.
AB.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net