If you need to limit the range of numeric values, you can use the solution described in this article: How to set a range for the CExtGridCellUpDown cell?. There are several virtual methods which allow you to entirely control the inplace edit.
- CExtGridCell::OnInplaceControlTextInputVerify()
and CExtGridWnd::OnGridCellInplaceControlTextInputVerify()
which called when the user is typing the text in the in-place editor. The methods return true if the text data has a valid format, otherwise false.
- CExtGridCell::OnParseText()
which is called to parse the text specified by the sText
parameter.
- CExtGridCell::OnInplaceControlPreTranslateMessage()
which performs the message pre-translation for the in-place active editor and returns true
if the message has been successfully filtered by the cell object.
Please take a look at these methods in the documentation. You can use them to implement custom parsing and filtering for the inplace editor.
virtual bool OnGridCellInplaceControlTextInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
__EXT_MFC_SAFE_LPCTSTR sTextInitial,
__EXT_MFC_SAFE_LPCTSTR sTextPrevious,
CExtSafeString & sTextNew,
bool bEndEdit
);
If the
bEndEdit
parameter is
false
, then the method is invoked each time when the user changes the text in the editor. If the
bEndEdit
parameter is
true
, the editing is complete and you can return
true
or
false
depending on whether you want to apply or cancel the results of editing. Of course, you can use this method when the editing is complete. There are also several type-specific methods of this kind:
virtual bool OnGridCellInplaceControlDateTimeInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
COleDateTime dtInitial,
COleDateTime dtPrevious,
COleDateTime & dtNew,
bool bEndEdit
);
virtual bool OnGridCellInplaceControlDurationInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
COleDateTimeSpan dtSpanInitial,
COleDateTimeSpan dtSpanPrevious,
COleDateTimeSpan & dtSpanNew,
bool bEndEdit
);
virtual bool OnGridCellInplaceControlHotKeyInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
DWORD dwHotKeyInitial,
DWORD dwHotKeyPrevious,
DWORD & dwHotKeyNew,
bool bEndEdit
);
virtual bool OnGridCellInplaceControlSliderInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
INT nPosInitial,
INT nPosPrevious,
INT & nPosNew,
bool bEndEdit
);
virtual bool OnGridCellInplaceControlIPAddressInputVerify(
const CExtGridCell & _cell,
HWND hWndInplaceControl,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
DWORD dwIPAddressInitial,
DWORD dwIPAddressPrevious,
DWORD & dwIPAddressNew,
bool bEndEdit
);
The following virtual method allows you to catch the event when editing begins:
virtual bool OnGbwBeginEdit(
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
const RECT & rcCellExtra,
const RECT & rcCell,
const RECT & rcInplaceControl,
bool bContinueMsgLoop = true
);