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 » A question about CExtGridCellComboBox? Collapse All
Subject Author Date
Mofei Abudura Aug 8, 2006 - 4:21 AM

i have three grid cell, name cell1, cell2, cell3.
if cell1’s value is 0, then cell2 and cell3’s status is read only.
if cell1’s value is 1, then cell2 is edit enable and cell3 is read only.

i don’t know how to implement this, does anyone who knows?
thanks.

Mofei Abudura Aug 10, 2006 - 4:34 AM

Thank you very much for your explain.
I think i can solve this problem now.

Mofei Abudura Aug 9, 2006 - 1:20 AM

To Technical Support :
Thanks for your suggestion, but it not fit for me, because the nColNo & nRowNo are dynamic.
Actully what i want to know is how to cause other CExtPropertyValue’s Apply() method to be called.

Mofei Abudura Aug 8, 2006 - 8:26 PM

and how to use the CExtGridWnd created by step 1?

Mofei Abudura Aug 8, 2006 - 7:53 PM

class CMyPropertyValue: public CExtPropertyValue
{
public:
CMyPropertyValue()
{
    CExtGridCellComboBox * pValue =
    STATIC_DOWNCAST(
    CExtGridCellComboBox,
    ValueActiveGetByRTC( RUNTIME_CLASS(CExtGridCellComboBox) )
    );
ASSERT_VALID( pValue );

     ValueDefaultFromActive();
}
...
}

void CMyPropertyValue::Apply(CExtGridCell * pValue)
{
    CExtPropertyValue::Apply(pValue);
    SetSiblingGridStatus(); // see below
}

void CMyPropertyValue::SetSiblingGridStatus()
{
    // Set Each Cell under the category to Disabled
    CExtPropertyItem& parentItem = ItemParentGetRef();
    int itemCount = parentItem.ItemGetCount();
    for (int i = 0; i < itemCount; i++)
    {
CMyPropertyValue * pPProperty =
     dynamic_cast<CMyPropertyValue*> (parentItem.ItemGetAt(i));
        
if (pPProperty == this)        // Skip self
    continue;
CExtGridCellComboBox * pGridValue =
    STATIC_DOWNCAST(
CExtGridCellComboBox,
pPProperty->ValueActiveGet()
);
pGridValue->ModifyStyle(__EGCS_READ_ONLY);    
}
}

after SetSiblingGridStatus() execute, the grid cell is edit enable also, pls tell me why, tks.

Technical Support Aug 9, 2006 - 9:33 AM

You did previously specified that you are using the CExtPropertyGridCtrl property grid control, which is not a generic CExtGridWnd grid control. The CExtPropertyGridCtrl class is not a classis grid at all but rather a container for one or more CExtPropertyGridWnd tree grid windows and other bars like the combo box bar, toolbar and help tip bar. The property grid control is based on a property tree with the CExtPropertyStore being the root and other CExtPropertyCategory/CExtPropertyValue nodes implementing categories and values to be displayed in the tree grid windows inside the CExtPropertyGridCtrl property grid control. Each CExtPropertyValue object contains two grid cells: the default value and the current value (the default grid cell is needed so that the user can reset the current value using the context menu over the property value in the active tree grid window). All the tree grid windows contain cloned copies of the current grid cell object from each CExtPropertyValue object. When the user modifies a grid cell in the active tree grid window, the property grid control automatically synchronizes the grid cells of the same property value in other tree grid windows and the current cell value in the CExtPropertyValue object. So, if you have modified a grid cell stored as the current cell value inside the CExtPropertyValue object, then you should invoke the CExtPropertyGridCtrl::PropertyStoreSynchronize() method which will reload the content of the tree grids stored in the property grid control. In some cases this approach cannot be applied and you will need to walk trough all the tree grids, search grid cells corresponding to particular property value and modify them. You can get an array of all the CExtPropertyGridWnd tree grid windows and find the grid cells corresponding to the known property value using this code:

CExtPropertyValue * pPropertyValue = . . .
CExtGridCell * pCellSrc = pPropertyValue->ValueActiveGet();
    ASSERT_VALID( pCellSrc );
 
CExtPropertyGridCtrl * pPGC = . . .
CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
    pPGC->OnPgcQueryGrids( arrGrids );
INT nGridIdx = 0;
    for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )
    {
        CExtPropertyGridWnd * pPGW = arrGrids[ nGridIdx ];
        ASSERT_VALID( pPGW );
        HTREEITEM hTreeItem = pPGW->PropertyItemToTreeItem( pValue );
        if( hTreeItem == NULL )
            continue;
        CExtGridCell * pCellDst = pPGW->ItemGetCell( hTreeItem, 1 );
        if( pCellDst == NULL )
            continue;
        ASSERT_VALID( pCellDst );
    }

Technical Support Aug 8, 2006 - 7:12 AM

You can follow these steps:

1. Create a CExtGridWnd class and override the OnGridCellInplaceControlTextInputComplete (or OnGridCellInputComplete) in it. This method is called when in-place editing is complete. This will allow you to receive a notification when the user has changed the cell’s value.

2. In the overridden method check the nColNo and nRowNo parameters and if they specify the required cell (cell1 in your case), make other cells editable or read-only depending on the cell’s value.

3. You can make any cell in any grid window read-only by applying the __EGCS_READ_ONLY style to the cell object (by means of CExtGridCell::ModifyStyle()). Please note that this style does not disable activation of the cell editor, i.e. read-only cells use read-only inplace edit windows. This may be useful for copying cell text into clipboard. If you need to disable activation of the inplace editor at all, simply apply __EGCS_NO_INPLACE_CONTROL.