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.
Subject |
Author |
Date |
|
tera tera
|
Sep 7, 2009 - 9:05 PM
|
In CExtGridWnd, I want to perform the swap of the cell.
Is there the best command? 
|
|
Technical Support
|
Sep 8, 2009 - 1:19 PM
|
The following snippet code moves the row with the nRowNoToMove index into the new position before the row with the nDropBeforeRowNo index:
LONG nRowNoToMove = . . .
LONG nDropBeforeRowNo = . . .
CExtGridWnd & wndGrid = . . .
ASSERT( 0 <= nDropBeforeRowNo && nDropBeforeRowNo <= wndGrid.RowCountGet() );
ASSERT( 0 <= nRowNoToMove && nRowNoToMove < wndGrid.RowCountGet() );
if( nDropBeforeRowNo <= nRowNoToMove && nRowNoToMove <= ( nDropBeforeRowNo + 1 ) )
return . . .
CExtGridDataProvider & _DataProvider = wndGrid.OnGridQueryDataProvider();
ULONG nOffset = 0L;
_DataProvider.CacheReservedCountsGet( NULL, &nOffset );
VERIFY( _DataProvider.SwapDroppedSeries( false, nRowNoToMove + nOffset, nDropBeforeRowNo + nOffset, &wndGrid ) );
The snippet code above is exactly the same as grid row drag-n-drop handling code in the CExtGridWnd::OnGridOuterDragComplete() virtual method. The code snippet above implements drag-n-dropping for one grid row. The grid cells inside the grid control does not become destroyed and created again. The selection and focus are modified inside the _DataProvider.SwapDroppedSeries( . . . ) method invocation and the same cells become focused and selected. You just need to invoke this code snippet twice to swap two rows.
|
|