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 » CExtGridCellComboBox + ResetContent BUG? Collapse All
Subject Author Date
Mike Van Duzee Dec 20, 2007 - 11:27 AM

When setting text on an CExtGridCellComboBox with the enum mode set to false, the current selection is not set. In the assign (CExtGridCellComboBox::Assign) the enum mode is ignored and the text/selection is reset via ResetContent.

Example:

-Create a CextGridCellComboBox.
-SetEnumMode(false).
-CextGridCellComboBox::AddString("An_Item").
-TextSet("An_Item").

When assign is called the text is lost. Should the current text be saved and restored in CExtGridCellComboBox::Assign, if no Selection was set.

Example:

void CExtGridCellComboBox::Assign( const CExtGridCell & other )
{
ASSERT_VALID( this );
CExtGridCellString::Assign( other );
CExtGridCellComboBox * pCell =
DYNAMIC_DOWNCAST(
CExtGridCellComboBox,
( const_cast < CExtGridCell * > ( &other ) )
);

CExtSafeString currentText = "";
if( ! GetEnumMode() )
this->TextGet( currentText );

ResetContent();
if( pCell != NULL )
{
// copy cell items
ITEM_INFO * pItemCurSel = NULL;
LONG nItem = 0;
for( nItem = 0; nItem < pCell->m_arrItems.GetSize(); nItem++ )
{
ITEM_INFO * pOtherItem = pCell->m_arrItems[ nItem ];
ITEM_INFO * pNewItem = new ITEM_INFO( *pOtherItem );
m_arrItems.Add( pNewItem );
if( pCell->m_pCurSel == pOtherItem )
pItemCurSel = pNewItem;
}
m_bEnumMode = pCell->m_bEnumMode;
SetImageList( pCell->m_pImageList );
if( pItemCurSel != NULL )
{
nItem = _GetIndexOf( pItemCurSel );
SetCurSel( nItem );
}
else
this->TextSet(currentText);

} // if( pCell != NULL )
}

Mike Van Duzee Dec 21, 2007 - 12:27 PM

Thats great... thanks a lot.

Technical Support Dec 21, 2007 - 12:19 PM

Actually we think it is enough to invoke the CExtGridCellString::Assign( other ) after ResetContent() but your way is also acceptable. Only one comment. The Assign method entirely assigns the content of the other cell. So you should not save own text value and copy text value from the other cell. Here is our modified code. Please check it.

void CExtGridCellComboBox::Assign( const CExtGridCell & other )
{
            ASSERT_VALID( this );
            CExtGridCellString::Assign( other );
CExtGridCellComboBox * pCell =
                        DYNAMIC_DOWNCAST(
                                   CExtGridCellComboBox,
                                   ( const_cast < CExtGridCell * > ( &other ) )
                                   );
            ResetContent();
            if( pCell != NULL )
            {
                        // copy cell items
                        ITEM_INFO * pItemCurSel = NULL;
                        LONG nItem = 0;
                        for( nItem = 0; nItem < pCell->m_arrItems.GetSize(); nItem++ )
                        {
                                   ITEM_INFO * pOtherItem = pCell->m_arrItems[ nItem ];
                                   ITEM_INFO * pNewItem = new ITEM_INFO( *pOtherItem );
                                   m_arrItems.Add( pNewItem );
                                   if( pCell->m_pCurSel == pOtherItem )
                                               pItemCurSel = pNewItem;
                        }
                        m_bEnumMode = pCell->m_bEnumMode;
                        SetImageList( pCell->m_pImageList );
                        if( pItemCurSel != NULL )
                        {
                                   nItem = _GetIndexOf( pItemCurSel );
                                   SetCurSel( nItem );
                        }
                        else
                                   pCell->TextGet( m_str );
            } // if( pCell != NULL )
}