MFC Grid manual

How do I take a control on the edit in place?

The grid provides a possibility to customize all edit in place operations. The best way is to use the CEditInPlace interface

//This example shows how to apply values to the data object when a cell loses 
//the focus

//1. Lets define the custom edit in place interface
class CCustomEditInPlace : public Dapfor::GUI::CEditInPlace
{
public:
    //Pass 'true' to the base class. In this case this interface is automatically destroyed in the destructor of the CGrid
    CCustomEditInPlace() : Dapfor::GUI::CEditInPlace(true)
    {
    }
    
    
    //Overrides the CEditInPlace's method
    virtual bool CanApply(Dapfor::GUI::CEditInPlace::StopReason reason) const
    {
        switch(reason)
        {
        //Set a new value to the data object when the next operations occur
        case Dapfor::GUI::CEditInPlace::LostFocus:
        case Dapfor::GUI::CEditInPlace::KeyUp:
        case Dapfor::GUI::CEditInPlace::KeyDown:
        case Dapfor::GUI::CEditInPlace::KeyLeft:
        case Dapfor::GUI::CEditInPlace::KeyRight:
        case Dapfor::GUI::CEditInPlace::KeyTab:
        case Dapfor::GUI::CEditInPlace::KeyShiftTab:
        case Dapfor::GUI::CEditInPlace::KeyCtrlTab:
                return true;
            
        default:
            //Otherwise, the default implementation will apply a new value in case of the next events:
            //(KeyReturn, ComboSelEndOk, MouseLBDblClick and UserStop)
            return CEditInPlace::CanApply(reason);
        }
    }
};

//2. To set a new implementation use the following:

//Set a new implementation of the edit in place interface
//The grid destroys this object in its own destructor
m_Grid.SetEditInPlace(new CCustomEditInPlace());