Professional UI Solutions
Site Map   /  Register
 
 

Forum

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 General Discussion » Check Box in Grid Cell Collapse All
Subject Author Date
Nader Mimouni May 3, 2006 - 7:01 AM

Good Day,

I want to get more info how to implemant a grid cell containing check box, how to handle click event on the check box and how to get its status ??

Many Thanks for your support !!!

Ou Shanhu Oct 7, 2007 - 10:47 AM

In fact, there is a more simple way to realize this function without override OnGridCellInputComplete.

void CMyView::OnButtonApply()
{
    ......
    CExtGridCellCheckBox* pCellCheckBox;
    LONG nRowNo = 0;
INT nStatus = 0;
    ......
    for( ... )
    {
        pCellCheckBox =
        STATIC_DOWNCAST(
            CExtGridCellCheckBox,
            m_wndGrid.GridCellGet(
                    0L,
                    nRowNo,
                    0,
                    0,
                    RUNTIME_CLASS(CExtGridCellCheckBox)
                    )
                );
        nStatus = (pCellCheckBox->GetCheck()) ? 1 : 0;
    
        nRowNo++;
    }

    ......

    return;
}

In the corresponding .h file, define m_wndGrid:
CMyGridWnd m_wndGrid;

CMyGridWnd is a class derived from CExtGridWnd.

Technical Support May 3, 2006 - 10:49 AM

Simply use the CExtGridCellCheckBox class for any cell that looks like the check box:

CExtGridWnd * pWndGrid = . . .
LONG nColumnNo = . . .
LONG nRowNo = . . .
CExtGridCellCheckBox * pCheckBoxCell =
        DYNAMIC_DOWNCAST(
            CExtGridCellCheckBox,
            pWndGrid->GridCellGet(
                nColumnNo,
                nRowNo,
                0,
                0,
                RUNTIME_CLASS( CExtGridCellCheckBox )
                )
            );
    pCheckBoxCell->Set3StateMode( true OR false );
        pCheckBoxCell->SetCheck( 0 OR 1 OR 2 );
This code creates a check box cell inside the grid window. You can handle when the check state changes by using a CExtGridWnd-derived class which implements the OnGridCellInputComplete() virtual method:
void CYourGrid::OnGridCellInputComplete(
    CExtGridCell & _cell,
    LONG nColNo,
    LONG nRowNo,
    INT nColType,
    INT nRowType,
    HWND hWndInputControl
    )
{
    ASSERT_VALID( this );
    ASSERT_VALID( (&_cell) );
    CExtGridWnd::OnGridCellInputComplete(
        _cell,
        nColNo,
        nRowNo,
        nColType,
        nRowType,
        hWndInputControl
        );
    if( nColType != 0 || nRowType != 0 )
        return; // the cell is editable header cell - not data cell
CExtGridCellCheckBox * pCheckBoxCell =
        DYNAMIC_DOWNCAST(
            CExtGridCellCheckBox,
            &_cell
            );
    if( pCheckBoxCell == NULL )
        return; // edited cell is not a check box cell
    INT nCheck = pCheckBoxCell->GetCheck();
    . . .
}



Nader Mimouni May 4, 2006 - 6:55 AM

Many Thanks for your reply !!