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 |
|
Gary McHale
|
Apr 22, 2011 - 12:30 PM
|
The Formula Grid is very impressive, however, there is one minor bug with it; (1) When columns are inserted,column labels are not updated. The nearest column label is repeated. Another thing, this is probably by design, but is contrary to most spread-sheet implementations; (2) When multiple rows (or columns) are selected, and insert row or column is executed, we would expect multiple rows ( or columns) to be created. Currently, only one row (or column is created). regards.
|
|
Technical Support
|
Apr 26, 2011 - 9:41 AM
|
Thank you for reporting these issues. Both are related to the FormulaGrid sample application, not to the CExtFormulaGrid class. Please update the following four methods in the FormulaGrid sample application:
void CChildView::OnInsertRow()
{
ASSERT_VALID( this );
if( SelectionIsEmpty() )
return;
CExtGR2D _range;
SelectionRangeGet( _range );
CRect rcBounds = _range.GetRangeBounds();
LONG nInsertCount = _range.GetRangeBounds().Height() + 1L;
nInsertCount = max( nInsertCount, 1L );
RowInsert( rcBounds.top, nInsertCount );
const CExtFormulaDataManager & _FDM = OnGridQueryFormulaDataManager();
const CExtFormulaAlphabet & _FA = _FDM.OnQueryFormulaAlphabet();
bool bINM = _FA.GetInverseNamingMode();
LONG nRowNo = rcBounds.top, nRowCount = RowCountGet();
for( ; nRowNo < nRowCount; nRowNo ++ )
{
CExtGridCell * pCell = GridCellGetOuterAtLeft( 0L, nRowNo, RUNTIME_CLASS(CExtGridCellHeader) );
if( pCell == NULL )
continue;
ASSERT_VALID( pCell );
if( bINM )
{
pCell->ModifyStyle( __EGCS_TA_HORZ_CENTER );
CExtSafeString str = _FA.GetAlphaStr( nRowNo );
pCell->TextSet( LPCTSTR(str) );
}
else
pCell->ModifyStyle(
__EGCS_TA_HORZ_RIGHT|__EGCS_HDR_ROW_COLUMN_NUMBER
//|__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY
);
}
}
void CChildView::OnInsertColumn()
{
ASSERT_VALID( this );
if( SelectionIsEmpty() )
return;
CExtGR2D _range;
SelectionRangeGet( _range );
CRect rcBounds = _range.GetRangeBounds();
LONG nInsertCount = _range.GetRangeBounds().Width() + 1L;
nInsertCount = max( nInsertCount, 1L );
ColumnInsert( rcBounds.left, nInsertCount );
const CExtFormulaDataManager & _FDM = OnGridQueryFormulaDataManager();
const CExtFormulaAlphabet & _FA = _FDM.OnQueryFormulaAlphabet();
bool bINM = _FA.GetInverseNamingMode();
LONG nColNo = rcBounds.left, nColumnCount = ColumnCountGet();
for( ; nColNo < nColumnCount; nColNo ++ )
{
CExtGridCell * pCell = GridCellGetOuterAtTop( nColNo, 0L, RUNTIME_CLASS(CExtGridCellHeader) );
if( pCell == NULL )
continue;
ASSERT_VALID( pCell );
if( ! bINM )
{
pCell->ModifyStyle( __EGCS_TA_HORZ_CENTER );
CExtSafeString str = _FA.GetAlphaStr( nColNo );
pCell->TextSet( LPCTSTR(str) );
}
else
pCell->ModifyStyle(
__EGCS_TA_HORZ_RIGHT|__EGCS_HDR_ROW_COLUMN_NUMBER
//|__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY
);
}
}
void CChildView::OnDeleteRow()
{
ASSERT_VALID( this );
if( SelectionIsEmpty() )
return;
CExtGR2D _range;
SelectionRangeGet( _range );
CExtArray < LONG > _arr;
stat_ComputeArrayOfRows( _range, _arr, false );
LONG nMinRowNo = -1L, nRemovedCount = 0L, nIndex, nCount = LONG( _arr.GetSize() );
for( nIndex = 0; nIndex < nCount; nIndex ++ )
{
LONG nRowNo = _arr[ nIndex ];
RowRemove( nRowNo, 1L, false );
nRemovedCount ++;
if( nIndex == 0 )
nMinRowNo = nRowNo;
else
nMinRowNo = min( nMinRowNo, nRowNo );
}
if( nRemovedCount == 0L )
return;
ASSERT( nMinRowNo >= 0L );
const CExtFormulaDataManager & _FDM = OnGridQueryFormulaDataManager();
const CExtFormulaAlphabet & _FA = _FDM.OnQueryFormulaAlphabet();
bool bINM = _FA.GetInverseNamingMode();
LONG nRowNo = nMinRowNo, nRowCount = RowCountGet();
for( ; nRowNo < nRowCount; nRowNo ++ )
{
CExtGridCell * pCell = GridCellGetOuterAtLeft( 0L, nRowNo, RUNTIME_CLASS(CExtGridCellHeader) );
if( pCell == NULL )
continue;
ASSERT_VALID( pCell );
if( bINM )
{
pCell->ModifyStyle( __EGCS_TA_HORZ_CENTER );
CExtSafeString str = _FA.GetAlphaStr( nRowNo );
pCell->TextSet( LPCTSTR(str) );
}
else
pCell->ModifyStyle(
__EGCS_TA_HORZ_RIGHT|__EGCS_HDR_ROW_COLUMN_NUMBER
//|__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY
);
}
OnSwInvalidate( true );
OnSwUpdateScrollBars();
}
void CChildView::OnDeleteColumn()
{
ASSERT_VALID( this );
if( SelectionIsEmpty() )
return;
CExtGR2D _range;
SelectionRangeGet( _range );
CExtArray < LONG > _arr;
stat_ComputeArrayOfColumns( _range, _arr, false );
LONG nMinColNo = -1L, nRemovedCount = 0L, nIndex, nCount = LONG( _arr.GetSize() );
for( nIndex = 0; nIndex < nCount; nIndex ++ )
{
LONG nColNo = _arr[ nIndex ];
ColumnRemove( nColNo, 1L, false );
nRemovedCount ++;
if( nIndex == 0L )
nMinColNo = nColNo;
else
nMinColNo = min( nMinColNo, nColNo );
}
if( nRemovedCount == 0L )
return;
ASSERT( nMinColNo >= 0L );
const CExtFormulaDataManager & _FDM = OnGridQueryFormulaDataManager();
const CExtFormulaAlphabet & _FA = _FDM.OnQueryFormulaAlphabet();
bool bINM = _FA.GetInverseNamingMode();
LONG nColNo = nMinColNo, nColumnCount = ColumnCountGet();
for( ; nColNo < nColumnCount; nColNo ++ )
{
CExtGridCell * pCell = GridCellGetOuterAtTop( nColNo, 0L, RUNTIME_CLASS(CExtGridCellHeader) );
if( pCell == NULL )
continue;
ASSERT_VALID( pCell );
if( ! bINM )
{
pCell->ModifyStyle( __EGCS_TA_HORZ_CENTER );
CExtSafeString str = _FA.GetAlphaStr( nColNo );
pCell->TextSet( LPCTSTR(str) );
}
else
pCell->ModifyStyle(
__EGCS_TA_HORZ_RIGHT|__EGCS_HDR_ROW_COLUMN_NUMBER
//|__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY
);
}
OnSwInvalidate( true );
OnSwUpdateScrollBars();
}
|
|