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 » really dumb question about CExtGridCellString Collapse All
Subject Author Date
Krustys Donuts Aug 25, 2005 - 4:02 PM

Hi, I have a CExtGridCellString, and want to dynamically change its text. I got a pointer to the cell using ValueActiveGet(), and then set the text using TextSet(). However, the text doesn’t update! I am wondering if I’m supposed to explicitly redraw the window, and if so, what method do I call?

Technical Support Aug 26, 2005 - 6:47 AM

You need to explicitly redraw the property grid window when you change cell values programmatically:

m_PGC.OnSwUpdateScrollBars();
m_PGC.OnSwDoRedraw();

Krustys Donuts Aug 26, 2005 - 7:05 AM

Hi, thanks... just to clarify for other here, the actual call from a property grid ctrl subclass is:

GetActiveGrid()->OnSwUpdateScrollBars();
GetActiveGrid()->OnSwDoRedraw();


However, for some reason, this still doesn’t work. Here’s what my code snippet looks like:

CExtPropertyCategory* pCategory = static_cast<CExtPropertyCategory*>(store.ItemGetAt( 0));
int numProperties = pCategory->ItemGetCount();
for( int i=0; i<numProperties; i++) {
    CExtPropertyItem* pItem = pCategory->ItemGetAt( i);
    string name = pItem->NameGet();
    if( name != "donut with sprinkles")
        continue;
    CExtGridCellString* pCell = dynamic_cast<CExtGridCellString*>(pItem->ValueActiveGet());
    pCell->TextSet( editboxes[name].c_str());  // the editboxes[name] is just a dynamically generated name
}
GetActiveGrid()->OnSwUpdateScrollBars();
GetActiveGrid()->OnSwDoRedraw();


The autogenerated text is correct when looking at the watch variable. After the calls to OnSw...(), the text still doesn’t update!

Technical Support Aug 26, 2005 - 1:02 PM

The CExtPropertyValue class contains two CExtGridCell objects describing the active and default values of a property. Your code gets a pointer to the active value cell and changes it absolutely correctly. But the grid windows inside the property grid control contains copies of the grid cell objects being modified by your code and the property grid control needs to be synchronized with the CExtPropertyGridCtrl::PropertyStoreSynchronize() method. Alternatively you can traverse all the grid windows inside the property grid control, find the cell objects corresponding to the property value and modify them:

CExtPropertyGridCtrl & _PGC = . . .
CExtPropertyValue * pValue = . . .
CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
    _PGC.OnPgcQueryGrids( arrGrids );
INT nGridIdx = 0;
    for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )
    {
        CExtPropertyGridWnd * pGrid = arrGrids[ nGridIdx ];
        ASSERT_VALID( pGrid );
        HTREEITEM hTreeItem =
            pGrid->PropertyItemToTreeItem( pValue );
        if( hTreeItem == NULL )
            continue;
        CExtGridCell * pCell =
            pGrid->ItemGetCell( hTreeItem, 1 );
        if( pCell == NULL )
            continue; 
        ASSERT_VALID( pCell );
        pCell->TextSet( . . . );
        // REDRAW MODIFIED CELL ONLY:
        if( (pGrid->GetStyle()&WS_VISIBLE) == 0 )
            continue;
        LONG nPlainIndex =
            pGrid->ItemGetVisibleIndexOf( hTreeItem );
        if( nPlainIndex < 0 )
            continue;
        CRect rc;
        pGrid->GridCellRectsGet(
            1, nPlainIndex, 0, 0, NULL, &rc );
        pGrid->InvalidateRect( &rc );
        pGrid->UpdateWindow();
    } // for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )