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 » How do I display a warning message when user drag and remove a column. Collapse All
Subject Author Date
Robert Hofstetter Aug 27, 2009 - 7:23 PM

I am using CExtReportGridWnd.   I’d like to warn users for accidental drag and remove a column

and how to cancel the operation if user want?

Technical Support Aug 28, 2009 - 1:40 PM

It’s possible to prevent drag-n-dropping of particular columns. You can apply the __EGCS_EX_DISABLE_START_DRAG extended grid cell style to CExtReportGridColumn report grid column objects (they are really instances of grid header cells displayed at the top header area of the CExtReportGridWnd report grid control). If you need to display some message about the disabled drag-n-drop behavior for particular report grid column, then you should define your own CExtReportGridColumn-derived class and implement the CExtReportGridColumn::DragDropEnabledGet() virtual method in it. This method can display some message box before returning the false flag. The CExtReportGridWnd::ReportColumnRegister() method allows you to specify the run-time class information of your CExtReportGridColumn-derived class.

You can allow your users to drag-n-drop any columns. But you can disable the removing of particular columns via dragging them out of the header area of the report grid control. The CExtGridWnd::OnGridOuterDragOut virtual method allows you to catch the column dragging out even. You can override it without invoking the parent class method and this will disable the dragging out of header columns in the CExtGridWnd, CExtTreeGridWnd and CExtReportGridWnd controls.

The two solutions above are described just for some advanced tricks you may need in the future.

There is the third solution which is more simple. The report grid column hiding action is called the report column de-activation. This action is always performed via the CExtReportGridWnd::ReportColumnActivate() virtual method invocation:

virtual bool ReportColumnActivate( // default parameters will activate/deactivate all the columns
            __EXT_MFC_SAFE_LPCTSTR strColumnName = NULL,
            __EXT_MFC_SAFE_LPCTSTR strCategoryName = NULL,
            bool bActivate = true,
            LONG nColNo = -1L, // -1L - activate last
            bool bRedraw = true

You can override this virtual method in your CExtReportGridWnd-derived class and invoke the parent class method with the bActivate flag parameter set to true flag for the columns which must be never deactivated by user. This third solution looks like the most simple and fitting your needs. It also allows to display message boxes with some warning messages for particular columns.