Professional UI Solutions
Site Map   /  Register


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 » Enable/Disable option for a property in a property grid Collapse All
Subject Author Date
Malcolm D Mar 29, 2007 - 7:26 PM

Is it possible to have a check box for a user to enable or disable a property of any type in a property grid cell. When the check box is off then the property is greyed out. In this case the user cannot modify the value.
The general idea is for the user to be able to specify if somethings has a property or not, or if they are overiding a default value by specifying a value.

When the check box is off then the property is greyed out. Not sure what is the correct way to go if you are viewing properties for multiple objects and for one the item is disabled and forf the other the item is disabled. I’m not sure in this case whether the item should be disabled or not , i.e. whether they can modify the value or not

In the propety cell you would see:
| "Check box" <Property Name> | <property value> |

Malcolm D Jul 10, 2007 - 11:04 PM

Now that we have your software I have had a go at implementing the enable/disable checkboxes on property items.
I was able to add the items by overloading the functions you suggested and adding my own class derived from CExtPropertyValue which has options to tell whether the check boxes are displayed or not on a per item basis. The OnSynchronizeInputEnabledCheckMark then sees it the property value is of the desired class, and then determines whether to show the check box or not. It’s not my favorite way of doing things since it involves cuting and pasting code and modifying a bit (and then making sure the code that was copied doesn’t get changed in later releases of your framework)

It would be good if there is a built in mechanism to do this. I have noticed in the this forum and the other one that two other people have asked for the same thing, so it might be a good thing.

I also noticed that you have some code commented out in association with OnInputEnabledGet to enable "disabling of a parent to treat the child as disabled whether or not it had check box - this was a behaviour I was hoping we would have, as opposed to what you have allowed : ticking the parent just tickes the childs tick box. If we had a choise of which type of behaviour we could have that would be better, since it seems these to systems are mutually incompatible. I wouldn’t want ticking the parent to tick the child, but enabling the parent would enable all children, regardless of having check boxes or not, unless the child itself was disabled.

Tell me what you think.

Malcolm D May 31, 2007 - 4:36 PM

How do you show the check boxes on a per item basis?
Is there some method/ property of CPropertyGridItem to do this, as this is where I would expect it to be.


Technical Support Jun 2, 2007 - 7:05 AM

You can achieve this by overriding the CExtPropertyGridWnd::_OnSynchronizeInputEnabledCheckMark() internal virtual method in both the CExtPropertyGridWndCategorized and CExtPropertyGridWndSorted classed. 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 /*m_bInputEnabledNestedFlags*/ ) )
                        pCellCaption->ModifyStyle( __EGCS_CHECKED );
                        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 /*m_bInputEnabledNestedFlags*/ ) )
                              pCellCaption->ModifyStyle( __EGCS_CHECKED, 0 );
                              pCellValue->ModifyStyle( 0, __EGCS_READ_ONLY|__EGCS_NO_INPLACE_CONTROL );
                        } // if( pPropertyItem->OnInputEnabledGet( false /*m_bInputEnabledNestedFlags*/ ) )
                              pCellCaption->ModifyStyle( 0, __EGCS_CHECKED );
                              pCellValue->ModifyStyle( __EGCS_READ_ONLY|__EGCS_NO_INPLACE_CONTROL, 0 );
                        } // else from if( pPropertyItem->OnInputEnabledGet( false /*m_bInputEnabledNestedFlags*/ ) )
                  } // 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 );
            CExtPropertyGridWndCategorized * pGridCategorized =
                  new CExtPropertyGridWndCategorized( this );
            pGridCategorized->m_bAutoDeleteWindow = true;
            if( ! pGridCategorized->Create(
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED;
            CExtPropertyGridWndSorted * pGridSorted =
                  new CExtPropertyGridWndSorted( this );
            pGridSorted->m_bAutoDeleteWindow = true;
            if( ! pGridSorted->Create(
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_SORTED;
      catch( ... )
            return false;
      return true;

Malcolm D May 31, 2007 - 12:05 AM

Hi guys.

I downloaded the latest trial to see if it had what we wanted.
There was no mention of this feature in the list for 2.70, but I decided to check to see if it had it anyway.

I did find the following items:
.. InputEnabledSet()
.. OnInput ...

I noticed there was no documentation for these items (in the chm help file)
I also have not been able to find the way to make the check boxes display, which are for enabling/disabling a specific item.

Any clues.
Is this feature (described in this thread ) in 2.70?
If so, what methods/ classes are for making use of it? If not, when is it coming?

Technical Support May 31, 2007 - 6:20 AM

Yes, we have not yet documented this feature partially because it is not standard. 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 = . . .
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 of the "input enabled" check marks in the property tree.

Malcolm D Apr 16, 2007 - 6:00 PM

Thanks guys for going ahead with this.

The first thing I noticed. All the items had check boxes. I saw the check boxes as being specific to an item. i.e. one item could have it and others wouldn’t, not all items having check boxes. This is one of the main things (maybe I didn’t spell it out explicitly)

The other point, which is not quite as important: if a category had a check box, this would then enable or disable all its children. I understand that this might cause issues with the sorted view.


Technical Support Apr 17, 2007 - 2:05 AM

Currently the following design is implemented:

1) Each CExtPropertyItem supports an input-enabled flag independently from any other property item (parent or child). The CExtPropertyCategory and CExtPropertyValue classes are derived from CExtPropertyItem.

2) The CExtPropertyGridCtrl class supports two modes of the input-enable check box processing: for each property item independently from any other property item; with mutual dependency between parent/children property items in the property store (like you can see in the sample test application). These modes can be selected by the user.

3) The CExtPropertyGridCtrl class can be configured so it displays the input-enabled check boxes for categories and/or values independently from each other and independently for each tree grid window in the property grid control.
The current beta design of the input-enabled feature does not support per-CExtPropertyItem visibility of the input-enabled check boxes. But this can be implemented as a new option of the CExtPropertyItem class and/or new virtual method of the CExtPropertyGridCtrl class. The mutual dependency of the input enabled check boxes between parent/children property items currently can be turned on/off for entire property store only and not for some sub-tree.

We will be glad to hear any additional comments from you before releasing the first version of the input-enabled feature.

Malcolm D Apr 3, 2007 - 4:59 PM

I am thinking that the check box should always be displayed.

For the case where the item has no children I would definitely want it to show. Though I understand that for consistancy you want to have the same behaviour in all situations.
I understand that the consequence of this is that if a category is disabled, then the children will be disabled, even when the parent is not showing. This may cause confusion for users if presented with such a case.

Maybe there needs to be an extra setting for for controlling the behaviour in the sorted mode.

If I didn’t have the check boxes displaying, then for me it would be better not to allow the sorted mode.

Technical Support Apr 16, 2007 - 11:25 AM

We have just coded input-enabled check marks feature in the property grid control. Please download this sample and let us know your point of view.

Malcolm D Apr 3, 2007 - 12:19 AM

One thing I think I forget to add, it would be good to be notified when the property is enabled/ disabled via this check box.

Technical Support Apr 3, 2007 - 9:06 AM

Yes, some virtual methods like OnItemInputEnabledStateChanging()/OnItemInputEnabledStateChanged() should be added to the CExtPropertyGridCtrl class.

There is one more thing to be discussed: we think the "input enabled" check boxes should be displayed in the categorized tree grid only because input-enabled state of the property item depends on the input-enabled state of its parent item. The children-parent hierarchy is not visible in the sorted tree grid.

Malcolm D Apr 3, 2007 - 12:16 AM

I think this is correct.


Malcolm D Apr 1, 2007 - 5:19 PM

Well, could I request it.


Technical Support Apr 2, 2007 - 9:03 AM

It is not a problem to insert check boxes into the grid cells which are displaying property/category names, but the checked value should be stored somewhere. We could modify the CExtPropertyItem class by adding some InputEnabledGet() and InputEnabledSet() methods to it, which get and set a flag value used by the check box. The input-enabled state of all the children property branch could be synchronized automatically. If the input is not enabled, the data grid cells in the property grid control should be displayed with some alternative style. Please confirm this is what you are looking for.

Technical Support Mar 30, 2007 - 12:20 PM

No, it is not supported.