Any grid cell supports three built-in buttons: up-down spin button, drop-down button and ellipsis button. Many grid cells perform event handling for these buttons and change their values. You should use the CExtGridCell::ModifyStyle()
method for a particular grid cell and specify the following styles to enable a button for this cell: __EGCS_BUTTON_UPDOWN, __EGCS_BUTTON_DROPDOWN
and/or __EGCS_BUTTON_ELLIPSIS.
You can create your CExtGridCell
-derived class and override the following virtual method to catch the button click event:
virtual void OnButtonPressed(
CExtGridWnd & wndGrid,
INT nButtonType,
const RECT & rcCellExtra,
const RECT & rcCell,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType
);
The
nButtonType
parameter can be equal to one of the following enumeration constants:
CExtGridCell::__EBTT_UPDOWN_UP, CExtGridCell::__EBTT_UPDOWN_DOWN, CExtGridCell::__EBTT_DROPDOWN
or
CExtGridCell::__EBTT_ELLIPSIS.
You can avoid coding your cell classes and handle the button clicks for all the grid cells in your
CExtGridWnd
-derived class which implements the following virtual method and which should return
true
if it handles the click event:
virtual bool OnGridCellButtonPressed(
CExtGridCell & _cell,
INT nButtonType,
const RECT & rcCellExtra,
const RECT & rcCell,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType
);
You need to code a
CExtGridCell
-derived class if you want to change the enabled state of cell buttons. In this case you should override the following virtual method:
virtual bool OnQueryButtonInfo(
INT nButtonType,
bool * p_bEnabled,
bool * p_bPressed = NULL,
bool * p_bStayPressed = NULL,
UINT * p_nTimerElapseValue = NULL
) const;
Using your
CExtGridCell
-derived class is also convenient to handle clicks on up and down parts of the spin button and update the enabled state of the up and down buttons independently from each other. This can be done by overriding the following methods:
virtual bool OnQueryEnabledIncrement() const;
virtual bool OnQueryEnabledDecrement() const;
virtual bool OnValueIncrement();
virtual bool OnValueDecrement();