Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » What's the proper way to know when a user has changed a cell value in CExtGridWnd? Collapse All
Subject Author Date
Scott Moore Jan 23, 2009 - 8:49 PM

I have a grid of cell values that the user can view and possibly edit.  When they edit a value, I will submit the new value to a server and validate it. 

But I’m not sure of the proper way to do it.  Initially, I think I should override the OnGbwBeginEdit method and set a flag that the user is editing a value.  But there isn’t a OnGbwEndEdit method.

My best guess is to use the OnGbwFocusChanging to know when the user has finished editing a value.  Is this the best way to know when the user has finished editing a grid value?

Thanks for any help.



Scott Moore Feb 2, 2009 - 3:30 PM

Why doesn’t OnGbwBeingEdit get called before editing begins on a cell?  I need to detect when a user is about to edit a cell so I can determine if the input should be masked or not (e.g., password field).


Technical Support Feb 3, 2009 - 12:31 PM

You should apply the __EGWS_BSE_EDIT_DOUBLE_LCLICK style to your grid window using its CExtGridWnd::BseModifyStyle() method. This style is present in grid by default because it’s listed in the definition of the __EGWS_BSE_DEFAULT preprocessor variable. Please check whether you removed this style during grid initialization.

Offer Har Jan 24, 2009 - 8:04 AM

Override CExtGridWnd::OnGridCellInputComplete

Called when the user finished the in-place edit.

Scott Moore Jan 28, 2009 - 8:02 AM

Thanks, that worked.


Something I can’t seem to figure out though is OnGbwBeginEdit().  That never gets called when I double-click a cell and start editing.  But if I click in another cell while editing, then it gets called right before the editor disappears.

How can I figure out when a cell value is about to be editied?


Technical Support Jan 28, 2009 - 11:44 AM

The following virtual method is invoked for all the grid cells when editing is complete and cell value is changed:

   virtual void OnGridCellInputComplete(
                        CExtGridCell & _cell,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType,
                        HWND hWndInputControl = NULL
The following virtual method is invoked during text typing (bEndEdit==false) and finally before editor window closing (bEndEdit==true) and allows you to verify edited text:
   virtual bool OnInplaceControlTextInputVerify(
                        HWND hWndInplaceControl,
                        CExtGridWnd & wndGrid,
                        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
                        ) const;
If the edited text is not valid, then you can simply return false to roll back the last text changing. You can also modify the sTextNew text.

Scott Moore Jan 28, 2009 - 2:17 PM

What method is invoked at the time editing begins?

OnGbwBeginEdit() does not get called when I double click a cell and begin editing the value.