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 General Discussion » CPropertyGridCtrl questions Collapse All
Subject Author Date
Peter Kester Oct 8, 2006 - 9:48 AM

1) What is the best method to remove a property store from the Property grid?
For example if you call PropertyStoreRemove() when this property store is active it will throw an ASSERT

I’m now using this function to remove a property store dynamically, but there muyst be a safer way, right?

bool CMyPropertyGridCtrl::PropertyStoreRemove(CExtPropertyStore *pPropertyStore)
{
CExtPropertyGridComboBoxBar * pCBB = STATIC_DOWNCAST(CExtPropertyGridComboBoxBar, GetChildByRTC(RUNTIME_CLASS(CExtPropertyGridComboBoxBar)));

if (PropertyStoreGet() == pPropertyStore)
{
// select first property store
pCBB->SetCurSel(0);
CExtPropertyStore * pPS = pCBB->PropertyStoreGetAt(0);
PropertyStoreSet(pPS);
}

for (INT nPos=0; nPos<pCBB->PropertyStoreGetCount(); nPos++)
{
CExtPropertyStore *pPS = pCBB->PropertyStoreGetAt(nPos);
if (pPS == pPropertyStore)
{
return pCBB->PropertyStoreRemove(nPos);
}
}
return false;
}

2) Is it possible to update the value of a CExtPropertyItem without rebuilding the complete propertygrid using PropertyStoreSynchronize()
I have an application where you can move objects and I want to update it’s position in my propertygrid, but it becomes very slow if you need to call PropertyStoreSynchronize() with every pixel the object is moved.

Technical Support Oct 9, 2006 - 8:49 AM

The CExtPropertyGridCtrl::PropertyStoreSet() method can have the NULL pointer as the parameter and your code does should do such property store assignment in case of removing the last property store.

You can traverse all tree grids inside the property grid control programmatically, find the grid cells corresponding to a particular property value and change the grid cell’s data:

CExtPropertyValue * pPropertyValue = . . . 
CExtPropertyGridCtrl * pPGC = . . .
CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
    pPGC->OnPgcQueryGrids( arrGrids );
INT nGridIdx, nGridCount = arrGrids.GetSize();
    for( nGridIdx = 0; nGridIdx < nGridCount; nGridIdx ++ )
    {
        CExtPropertyGridWnd * pGrid = arrGrids[ nGridIdx ];
        ASSERT_VALID( pGrid );
        HTREEITEM hTreeItem = pGrid->PropertyItemToTreeItem( pPropertyValue );
        if( hTreeItem == NULL )
            continue;
        CExtGridCell * pCell = pGrid->ItemGetCell( hTreeItem, 1 );
        if( pCell == NULL )
            continue;
        ASSERT_VALID( pCell );
        //
        // TO DO: modify pCell data here
        //
    }
Please note that grid cells inside tree grids are cloned copies of the active grid cell values inside the CExtPropertyValue objects. So, your code can simply assign one grid cell object from another one.