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 » CExtPropertyGridCtrl enable/disable question Collapse All
Subject Author Date
Offer Har Aug 21, 2006 - 11:09 PM

Dear Support,

I have a grid property grid control. I need according to user selection in another place to enable or disable an item or a full category.
How do i do this operation?

Best Regards,

Offer

Technical Support Aug 22, 2006 - 6:31 AM

The property grid control is based on a tree like data structure that contains property items: the CExtPropertyStore property store object (which is the root), CExtPropertyValue property values and CExtPropertyCategory property categories. All property items are derived from the CExtPropertyItem generic property item class. By default, all the property values and categories are enabled. You can emulate the disabled(grayed) state of the property values as it is demonstrated in the PropertyGrid sample (see the Window | Handle property value). You should simply set the __EGCS_READ_ONLY grid cell style for active/default grid cells of the property value:

CExtPropertyStore * pPS = . . .
CExtPropertyGridCtrl * pPGC = . . . // get it somehow from pPS
CExtPropertyItem * pPropertyItem = . . .
CExtPropertyValue * pPropertyValue = DYNAMIC_DOWNCAST( CExtPropertyValue, pPropertyItem );
    if( pPropertyValue == NULL )
        return . . .
    pPropertyValue->ValueDefaultGetRef.ModifyStyle( __EGCS_READ_ONLY ); 
    pPropertyValue->ValueActiveGetRef.ModifyStyle( __EGCS_READ_ONLY );
Please note grid cells stored in the tree grid windows inside the property grid controls are exact copies of the active grid cells stored inside CExtPropertyValue objects in the property store’s tree. So finally do not forget to synchronize the property grid control’s content:
    pPGC->PropertyStoreSynchronize();

Offer Har Aug 23, 2006 - 8:32 AM

Dear Support.

This solution works for items inside a category. When i try to call this on a category (CExtPropertyCategory) it crashes in ValueDefaultGetRef and in ValueActiveGetRef (the function ValueActiveGet() returns NULL).

I need also to disable a full category (or hide it, whatever is possible).

Regards,

Offer

Technical Support Aug 24, 2006 - 7:51 AM

The disabled state of property values is emulated by the read-only state of the grid cells representing property values. Property categories do not contain grid cells, this is why it is not possible to make them looking disabled using the above described approach.

We would recommend you switch to hidden property values and categories instead of disabled because this solution is more user friendly: you can only work with available properties. If this suits you, please use a CExtPropertyValue-derived class instead of CExtPropertyValue and override the CExtPropertyItem::CanBeInsertedIntoPropertyGrid() virtual method. This method should return false if the property value is supposed not to appear in the property grid although it exists inside the property store’s tree. If all property values inside some property category cannot be inserted into the property grid control, then the category also cannot be inserted into it.

Offer Har Aug 25, 2006 - 7:29 AM

This sounds like a good idea.
My only concert is weather CanBeInsertedIntoPropertyGrid is call when i call PropertyStoreSynchronize or only when the property is first inserted into the categor/store.
I need to dynamically according to user selection elsewhere to change the content of the grid.

Thanks,

Offer

Technical Support Aug 25, 2006 - 7:42 AM

The CExtPropertyItem::CanBeInsertedIntoPropertyGrid() virtual method is invoked both when assigning a new property store to the property grid control or synchronizing an existing one. You should not have any problems with this approach.

Offer Har Aug 25, 2006 - 8:54 AM

Great!

Solved my problem.