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 » Property Grid - Add check-box in section row Collapse All
Subject Author Date
Offer Har Jun 2, 2007 - 5:45 PM

Dear Support,

I would like to add a check-box in a section header row, that when checked, all items in the section are enabled, and vice-versa.
Is it possible? If not, any suggestion of how to achieve this behavior?

Thanks,
Ron.

Malcolm D Jul 19, 2007 - 10:42 PM

I think so too (that’s why I asked for it in the first place)

Some things to improve
(i) Better support for having check boxes on only some items.
(ii) Make sure it works well when in a mixed property (when combining property stores) - maybe uses thrid check state if the children of the mixed property have different values - i.e. one disabled and the other enabled.
(iii) Have "strong" parent/child behaviour (applicable to categorized view only), where ticking the category enabled or disables all its children, where the children don’t necessarily need to have a check box. If a child does have a check box then ticking/ unticking the parents one doesn’t tick the childs one. In this case the child is only enabled if its check box is enabeld and the parents one is enabled too.


Thanks

Technical Support Jun 3, 2007 - 10:33 AM

The check boxes can be displayed or hidden in each tree grid window in the property grid control and independently of property categories (m_bInputEnabledCheckMarksInCategories) and property values(m_bInputEnabledCheckMarksInValues):

CExtPropertyGridCtrl * pPGC = . . .
      ASSERT_VALID( pPGC );
CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
      pPGC->OnPgcQueryGrids( arrGrids );
INT nGridIdx = 0;
      for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )
      {
            CExtPropertyGridWnd * pPGW = arrGrids[ nGridIdx ];
            ASSERT_VALID( pPGW );
            pPGW ->m_bInputEnabledCheckMarksInCategories = true; // or false
            pPGW ->m_bInputEnabledCheckMarksInValues = true; // or false
            pPGW ->m_bInputEnabledNestedFlags = true; // or false
      }
The m_bInputEnabledNestedFlags flag turns on/off the nested dependency on the "input enabled" check marks in the property tree.

Offer Har Jun 3, 2007 - 5:33 PM

Because I don’t have direct access to the cells, hod do I:
1. Get an event/virtual function to override when a cetegory check state have changed.
2. Get the check state of a check-box of a specific category.
3. Set the check state of a check-box of a specific category.

Thanks,
Ron.

Technical Support Jun 4, 2007 - 3:50 AM

Here are these methods:

1) The CExtPropertyGridCtrl::OnPgcPropertyInputEnabled() and CExtPropertyItem::OnInputEnabledSet() virtual methods.
2) The CExtPropertyItem::InputEnabledGet()method.
3) The CExtPropertyItem::InputEnabledSet() method.

Offer Har Jun 4, 2007 - 7:47 PM

Thanks.

Offer Har Jun 3, 2007 - 2:39 PM

I need the check-box in a specific category, and not in all of them.
The flag you specified is one that adds a check-box to all categories.

Technical Support Jun 4, 2007 - 3:48 AM

You can achieve this by overriding the CExtPropertyGridWnd::_OnSynchronizeInputEnabledCheckMark() internal virtual method in both the CExtPropertyGridWndCategorized and CExtPropertyGridWndSorted classes. The method defines the "input enabled" check boxes in grid cells. Here is the default implementation which you can modify in order to insert per-item check boxes:

void CExtPropertyGridWnd::_OnSynchronizeInputEnabledCheckMark(
      CExtPropertyItem * pPropertyItem,
      bool bSychronizeChildren // = true
      )
{
      ASSERT_VALID( this );
      ASSERT_VALID( pPropertyItem );
HTREEITEM hTreeItem = PropertyItemToTreeItem( pPropertyItem );
      if( hTreeItem != NULL )
      {
            CExtGridCell * pCellCaption = ItemGetCell( hTreeItem, 0L );
            ASSERT_VALID( pCellCaption );
            pCellCaption->ModifyStyle( 0, __EGCS_CHK_MASK );
            if( m_bInputEnabledCheckMarksInCategories && pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyCategory) ) )
            {
                  pCellCaption->ModifyStyle( __EGCS_CHK_CHECK );
                  if( pPropertyItem->OnInputEnabledGet( false ) )
                        pCellCaption->ModifyStyle( __EGCS_CHECKED );
                  else
                        pCellCaption->ModifyStyle( 0, __EGCS_CHECKED );
            } // if( m_bInputEnabledCheckMarksInCategories && pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyCategory) ) )
            CExtGridCell * pCellValue = ItemGetCell( hTreeItem, 1L );
            if( pCellValue != NULL )
            {
                  ASSERT_VALID( pCellValue );
                  if( m_bInputEnabledCheckMarksInValues && pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyValue) ) )
                  {
                        pCellCaption->ModifyStyle( __EGCS_CHK_CHECK );
                        if( pPropertyItem->OnInputEnabledGet( false ) )
                        {
                              pCellCaption->ModifyStyle( __EGCS_CHECKED, 0 );
                              pCellValue->ModifyStyle( 0, __EGCS_READ_ONLY|__EGCS_NO_INPLACE_CONTROL );
                        } // if( pPropertyItem->OnInputEnabledGet( false ) )
                        else
                        {
                              pCellCaption->ModifyStyle( 0, __EGCS_CHECKED );
                              pCellValue->ModifyStyle( __EGCS_READ_ONLY|__EGCS_NO_INPLACE_CONTROL, 0 );
                        } // else from if( pPropertyItem->OnInputEnabledGet( false ) )
                  } // if( m_bInputEnabledCheckMarksInValues && pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyValue) ) )
            } // if( pCellValue != NULL )
      } // if( hTreeItem != NULL )
      if( bSychronizeChildren )
      {
            INT nIndex, nCount = pPropertyItem->ItemGetCount();
            for( nIndex = 0; nIndex < nCount; nIndex++ )
            {
                  CExtPropertyItem * pItem = pPropertyItem->ItemGetAt( nIndex );
                  ASSERT_VALID( pItem );
                  _OnSynchronizeInputEnabledCheckMark( pItem, true );
            } // for( nIndex = 0; nIndex < nCount; nIndex++ )
      } // if( bSychronizeChildren )
}
Here is the CExtPropertyGridCtrl::OnPgcCreateGrids() virtual method in which you can instantiate your custom tree grid classes (instead of those created by default):
bool CExtPropertyGridCtrl::OnPgcCreateGrids()
{
      ASSERT_VALID( this );
      try
      {
            CExtPropertyGridWndCategorized * pGridCategorized =
                  new CExtPropertyGridWndCategorized( this );
            pGridCategorized->m_bAutoDeleteWindow = true;
            if( ! pGridCategorized->Create(
                        this,
                        __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED,
                        true
                        )
                  )
            {
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED;
            }
            CExtPropertyGridWndSorted * pGridSorted =
                  new CExtPropertyGridWndSorted( this );
            pGridSorted->m_bAutoDeleteWindow = true;
            if( ! pGridSorted->Create(
                        this,
                        __EXT_MFC_ID_PROPERTY_GRID_SORTED
                        )
                  )
            {
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_SORTED;
            }
      }
      catch( ... )
      {
            return false;
      }
      return true;
}

Offer Har Jun 4, 2007 - 7:48 PM

Thanks.
I think this a powerful feature, and you should consider adding it as an integral part of the library.