class CGXDateTimeCtrl: public CGXBDateTimeCtrl, public CGXStatic
The CGXDateTimeCtrl class implements a date/time control cell type that can be used to display and enter dates and times. CGXDateTimeCtrl derives from CGXBDateTimeCtrl (CGXB refers to CGX Base). CGXBDateTimeCtrl is largely based on the date/time control that ships with Objective Toolkit.
Style attributes that specify the appearance of the cell are:
-
Text with SetValue
-
Text color with SetColor
-
Background color with SetInterior.
-
Cell frame 3d-effect (raised, inset, normal) with SetDraw3dFrame
-
Borders with SetBorder
- Font with SetFont
Several other user attributes define important characteristics of the CGXDateTimeCtrl. They are defined and explained in detail under the description for CGXDateTimeCtrl::AddUserAttributes.
The date/time control is implemented as an aggregate of several gadgets, each of which performs a specialized function. For example, the numeric gadget is used to display and accept numeric input, and the spin gadget is used to provide the functionality of a spin control that manipulates the date/time value in another gadget (normally the gadget that has the input focus). Any CGXDateTimeCtrl would comprise these and other such gadgets. The layout of these gadgets is customizable and is based on the format in which you would like the date/time to be displayed.
The following control ids are predefined in Objective Grid for the date/time control:
You have the option of displaying the date/time control with or without a calendar.
-
GX_IDS_CTRL_DATETIMENOCAL – CGXDateTimeCtrl without drop-down calendar.
- GX_IDS_CTRL_DATETIME – CGXDateTimeCtrl with drop-down calendar.
You can apply the date/time control to cells with a call like the one shown below.
SetStyleRange(CGXRange(11,1),
CGXStyle()
.SetControl(GX_IDS_CTRL_DATETIMENOCAL)
.SetUserAttribute(GX_IDS_UA_DATEFORMATTYPE, str)
.SetValue(dt.Format())
);
where dt is an object of class COleDateTime. You can also use any string that can be parsed into a date/time value as the value in the call to SetValue.
Please look at the description of GX_IDS_UA_DATEFORMATTYPE for an explanation of this user attribute. This is under the description for CGXDateTimeCtrl::AddUserAttributes.
Note1:
The CGXDateTimeCtrl will assert if the user starts clicks into the cell and you enabled WYSIWYG mode. Do not permanently turn on WYSIWYG mode (GetParam()->SetDrawWYSIWYG(TRUE)) if you are using a datetime control in the grid. Use WYSIWYG mode only temporarily while doing grid operations like ResizeRowHeightsToFit.
Note2:
We have documented this class in detail to give you an idea of what’s going on behind the scenes and how we integrated an existing CWnd class as cell type into the grid. Therefore, the documentation of this class also refers to undocumented implementation classes (such as CGXBDateTimeCtrl).
This introduction to the class and the description of user attributes in CGXDateTimeCtrl::AddUserAttributes gives you all the information you need to use date and time cells in your grid.
#include <gxall.h>
See Also
CGXGridCore::RegisterControl CGXStyle::SetControl CGXStyle CGXDateTimeCtrl::AddUserAttributes