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 Tech Support » CExtGridWnd row double click Collapse All
Subject Author Date
Richard Gardner Feb 13, 2008 - 2:29 AM

Hi

how to catch the event when the user make a double click on a row and get a rowIndex for that row?
all the cells from row have styles
ModifyStyle(__EGCS_NO_INPLACE_CONTROL );
ModifyStyle(__EGCS_READ_ONLY, 0);
so user won’t go in edit mode. Also all cells are of type CExtGridCellString.

Grid is set that it does not allow multiple row selection.

The grid is created dynamically by calling
if (!m_Grid.Create(this))
{
ASSERT(FALSE);
return FALSE;
}

in OnInitDialog.

Thx

Technical Support Feb 18, 2008 - 5:33 AM

You should override the CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent() virtual method:

bool CYourGrid::OnGbwAnalyzeCellMouseClickEvent(
      UINT nChar, // VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only
      UINT nRepCnt, // 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing
      UINT nFlags, // mouse event flags
      CPoint point // mouse pointer in client coordinates
      )
{
      ASSERT_VALID( this );
      ASSERT( 0 <= nRepCnt && nRepCnt <= 3 );
      //
      // You should invoke parent class method first.
      // This will let grid window to process selection/focus by default.
      //
bool bRetVal =
            CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent(
                  nChar,
                  nRepCnt,
                  nFlags,
                  point
                  );
      //
      // Hit test the mouse click event and get grid cell.
      //
CExtGridHitTestInfo htInfo( point );
      HitTest( htInfo, false, true );
      if( (! htInfo.IsHoverEmpty() ) && htInfo.IsValidRect() )
      {
            INT nColType = htInfo.GetInnerOuterTypeOfColumn();
            INT nRowType = htInfo.GetInnerOuterTypeOfRow();
            CExtGridCell * pCell =
                  GridCellGet(
                        htInfo.m_nColNo,
                        htInfo.m_nRowNo,
                        nColType,
                        nRowType
                        );
            if( pCell != NULL )
            {
                  ASSERT_VALID( pCell );
                  if( nChar == VK_LBUTTON && nRepCnt == 2 )
                  {
                        //
                        // Some grid cell is double-clicked.
                        // It can be outer header cell or inner data cell.
                        //
                        if( nColType == 0 && nRowType == 0 )
                        {
                              //
                              // Some inner data cell is double-clicked.
                              // The htInfo.m_nColNo and htInfo.m_nRowNo properties
                              // are column and row indices.
                              //
                        }
                  }
            }
      }
      else
            bRetVal = false;
      return bRetVal;
}