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 » Grid cell end edit question Collapse All
Subject Author Date
Offer Har Jun 18, 2008 - 10:50 AM

I have a grid, and I want that when the user ends the in-place edit with an enrer key press, the focus will move to the cell below the one he finished edit.

How can this be done?



Technical Support Jun 19, 2008 - 5:32 AM

There is a similar functionality for arrow keys. You can turned it on by applying __EGWS_BSE_WALK to your grid. But if you need to make it work for the VK_RETURN key, you should implement it yourself. Please take a look at the CExtGridInplaceEdit::WindowProc() method and analyze the following code snippet. It implements moving to the next cell when the arrow key is pressed.

if( bTranslate )
            LRESULT lResult = 0L;
            HWND hWndParent = GetParent()->GetSafeHwnd();
            if( hWndParent != NULL )
                        HWND hWndOwn = m_hWnd;
                        HWND hWndGrid = m_wndGrid.m_hWnd;
                        CExtGridWnd * pWndGrid = &m_wndGrid;
                        _DoEndEdit( true );
                        lResult = ::SendMessage(hWndParent,WM_KEYDOWN,wParam,lParam);
                        if(                     ::IsWindow(hWndGrid)
                                    &&        ( ! ::IsWindow(hWndOwn) )
                                    &&        CWnd::FromHandlePermanent(hWndGrid) == pWndGrid
                                    ASSERT_VALID( pWndGrid );
            return lResult;
} // if( bTranslate )
Then analyze the code after the following line:
case VK_RETURN: 
It implements the behavior when the Return key is pressed.

So what you need to do is to declare a CExtGridInplaceEdit derived class. In it, override the WindowProc virtual method and add a handler for the VK_RETURN button like for the arrow keys. Then override the CExtGridCellString::OnInplaceControlCreate virtual method and create your inplace control there.