-
Time spoils when moving to another cell
When I enter 08:24 to a time cell and switch to another cell, I got 00:35 (sometimes when switching back to the time cell). This happens in all my applications.
Guys, give me a hope, say that your app works fine.
CGXStyle TimeStyle = CGXStyle().SetControl(GX_IDS_CTRL_DATETIMENOCAL).S etFormat(GX_FMT_TIME).SetUserAttribute(GX_IDS_UA_C USTOMFORMAT, _T(" HH:mm"));
OGrid 12.0.2
-
Hi Alex,
This problem is not reproducable with current version, OG 13.0.
Please, consider migration from obsolete 12.02 to the current one.
Regards,
Boris
-
This is because date time parsing in OGrid works in the following way:
When a value is entered in a cell it is converted to COleDateTime and m_dt member (double) is stored as a string (for 8:24 this string is "0.35").
Then when a cell is activated to be edited again, the stored double value is converted from a string to COleDataTime using the following code:
void CGXDateTimeCtrl::SetValue(LPCTSTR pszRawValue)
{
//...
COleDateTime dt;
if (pszRawValue == NULL || m_bForceStrValueAsNumber || !dt.ParseDateTime(pszRawValue))
{
if (pszRawValue != NULL && _tcslen(pszRawValue) > 0 && _gxttof(pszRawValue) != 0)
dt = _gxttof(pszRawValue);
}
// ...
}
When "0.35" string is passed to this method as pszRawValue the dt.ParseDateTime() call returns true because COleDateTime mistakenly treats this string as an ordinary time value (00:35).
When any other string (or almost any other) is passed to this method, dt.ParseDateTime() returns false and the string is converted to double by means of _gxttof (it is an alias of atof).
So it is "by design" and it seems that the correct way to fix this is to activate m_bForceStrValueAsNumber flag. This flag is activated by setting cell style attribute GX_IDS_UA_FORCESTRVALUEASNUMBER.
-
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules