GridControl::GetSelCell

 

Description

Gets selected cell's screen-coordinates position and row/column index.


Gets selected cell's row/column index.

Syntax

bool GetSelCell( int & nx, int & ny, int & nRow, int & nCol )

bool GetSelCell( int * pnRow, int * pnCol )

Parameters

nx
[output] selected cell's horizontal position in screen coordinates
ny
[output] selected cell's vertical position in screen coordinates
nRow
[output] selected cell's 0-offset row index
nCol
[output] selected cell's 0-offset column index

pnRow
[output] if it is not NULL, get selected cell's 0-offset row index
pnCol
[output] if it is not NULL, get selected cell's 0-offset column index

Return

false if no selected cell, otherwise true


false if no selected cell, otherwise true

Examples

This section describes how to use ctrl+C and ctrl+V to copy/paste the selected cell's value.

Example codes can be added to GridControl's examples to run

ON_GRID_KEY(IDC_GRID, OnKeyDown) //add to class GridCtrlDLG's Message Map 

//add in class GridCtrlDLG
        BOOL OnKeyDown(Control ctrl, UINT msg, UINT wParam, UINT lParam)
        {
                if( WM_KEYDOWN != msg )
                        return FALSE; 
                
                int nRow, nCol;
                m_GridCtrl.GetSelCell(&nRow, &nCol);
                
                switch( wParam )
                {
                case 'c': case 'C':
                        if( CNTRL_DOWN )
                                copy_to_clipboard(m_GridCtrl.GetCell(nRow, nCol), true, false);
                        
                        break;
                case 'v': case 'V':
                        if( CNTRL_DOWN )
                        {
                                string strVal;
                                if( GetClipboardText(strVal) )
                                        m_GridCtrl.SetCell(nRow, nCol, strVal);
                        }
                        break;
                }
                return TRUE;
        }

Remark

See Also

GridControl::FindCell

header to Included

GridControl.h