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 » bug in PropertyGridCtrl? Collapse All
Subject Author Date
Krustys Donuts Aug 24, 2005 - 8:07 AM

Hi, it doesn’t look like the PropertyGridCtrl is sorting correctly. If you select the category view, the underlying values are sorted alphabetically (which we don’t want to do). If we select the alphabetical view, the values are displayed in the order that they are added to the category.

If you run your PropertyGrid sample, you’ll notice two things: 1) the category view is sorted (which may not mean anything because you could have just added the items alphabetically), and 2) the alphabetical view sorts correctly, but clearly does so on a category-basis. Instead of sorting everything as a group, it sorts only within each category (which aren’t visible in this view).

I think that the category view should not ever sort, but should instead display values in the order added. The alphabetical view should sort across all items, since the categories aren’t visible at this point anyway. VS.NET works the same way.

Technical Support Aug 24, 2005 - 12:35 PM

Thank you for your comments and suggestions. To fix the behavior, please do the following three steps:

  1. Initialize m_bSortedValues to false in the CExtPropertyGridWnd::CExtPropertyGridWnd() constructor;
  2. Initialize m_bSortedValues to true in the CExtPropertyGridWndSorted::CExtPropertyGridWndSorted() constructor;
  3. Update the source code for the CExtPropertyGridWndSorted::PropertyStoreSynchronizeOneLevel() method:
    void CExtPropertyGridWndSorted::PropertyStoreSynchronizeOneLevel(
        CExtPropertyItem * pPropertyItem,
        CExtPropertyItem * pParentItem // = NULL
        )
    {
        ASSERT_VALID( this );
        ASSERT_VALID( pPropertyItem );
        pParentItem;
        if( pPropertyItem->IsKindOf(RUNTIME_CLASS(CExtPropertyValue)) )
        {
            HTREEITEM htiParent =
                ItemGetRoot();
            ASSERT( htiParent != NULL );
            HTREEITEM hTreeItem = NULL;
            if( ! m_bSortedValues )
            {
                hTreeItem = 
                    PropertyItemInsert(
                        pPropertyItem,
                        -1,
                        htiParent,
                        false
                        );
            }
            else
            {
                hTreeItem = 
                    PropertyItemInsertAlphabetic(
                        pPropertyItem,
                        htiParent,
                        false
                        );
            }
    // commented is the bug fix by Maurizio Pesce
    // properties are enabled to be hidden in grids
    //        ASSERT( hTreeItem != NULL );
    //        if( hTreeItem == NULL )
    //            return;
            hTreeItem;
            return;
        } // if( pPropertyItem->IsKindOf(RUNTIME_CLASS(CExtPropertyValue)) )
    INT nIndex, nCount = pPropertyItem->ItemGetCount();
        for( nIndex = 0; nIndex < nCount; nIndex ++ )
        {
            CExtPropertyItem * pChildItem =
                pPropertyItem->ItemGetAt( nIndex );
            PropertyStoreSynchronizeOneLevel( pChildItem, pPropertyItem );
        } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
    }