|
|
|
|
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.
Subject |
Author |
Date |
|
Offer Har
|
Oct 15, 2006 - 9:49 PM
|
Hi,
I have a property grid, and I need to display the indeterminate mode for a cell. The cell also contains a combo with the corresponding text (show for checked, hide for un-checked) When in the indeterminate state, I would like no text to be displayed. I tried setting the text to "", but i found out that if the text is not one of the show/hide (the true/false) texts, the LabelTextSet is ignored.
Is there a way around this problem? is there a smarter way of having a 3 state check-box like the standard check-box
Regards,
Offer
|
|
Offer Har
|
Oct 15, 2006 - 9:50 PM
|
Mistake in my problem description - the funcion TextSet is ignored, NOT LabelTextSet
|
|
Technical Support
|
Oct 16, 2006 - 11:28 AM
|
You can use the CExtGridCellCheckBox cell and initialize it in the following way: CExtGridCellBool::g_strTextTrue = _T("Show");
CExtGridCellBool::g_strTextFalse = _T("Hide");
pCellCheckBox->SetAutoTextMode( true );
pCellCheckBox->Set3StateMode( true );
pCellCheckBox->SetCheck( 2 ); // indeterminate state
|
|
Offer Har
|
Oct 16, 2006 - 8:33 PM
|
Hi,
Thanks, the 3 state works, but now there is no label. Even if I set the static variables, they do not appear. Also, I need them to change from cell to cell, so global variables is not a good idea.
Thanks.
|
|
Technical Support
|
Oct 17, 2006 - 11:16 AM
|
You can do this by overriding CExtGridCellCheckBox in the following way: //Declaration:
class CYourGridCellCheckBox : public CExtGridCellCheckBox
{
public:
DECLARE_SERIAL( CYourGridCellCheckBox );
IMPLEMENT_ExtGridCell_Clone( CYourGridCellCheckBox, CExtGridCellCheckBox);
CYourGridCellCheckBox(
CExtGridDataProvider * pDataProvider = NULL
);
virtual void TextGet( CExtSafeString & strCopy ) const;
};
//Implementation:
IMPLEMENT_SERIAL( CYourGridCellCheckBox, CExtGridCellCheckBox, VERSIONABLE_SCHEMA|1 );
...
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
...
CYourGridCellCheckBox::CYourGridCellCheckBox(
CExtGridDataProvider * pDataProvider // = NULL
)
: CExtGridCellCheckBox( pDataProvider )
{
}
void CYourGridCellCheckBox::TextGet( CExtSafeString & strCopy ) const
{
ASSERT_VALID( this );
if( (GetStyleEx()&__EGCS_EX_UNDEFINED_ROLE) != 0 )
{
strCopy = _T("");
return;
}
strCopy.Empty();
if( GetAutoTextMode() )
{
strCopy = _T("");
INT nCheck = GetCheck();
switch( nCheck )
{
case 0:
strCopy = _T("Hide");
break;
case 1:
strCopy = _T("Show");
break;
case 2:
strCopy = _T("Indeterminate");
break;
} // switch( nCheck )
return;
} // if( GetAutoTextMode() )
CExtGridCellCheckBox::TextGet( strCopy );
} Here is how this class should be initialized: CYourGridCellCheckBox * pCellCheckBox0 =
STATIC_DOWNCAST(
CYourGridCellCheckBox,
m_wndGrid.GridCellGet(
nColNo,
0L,
0,
0,
RUNTIME_CLASS(CYourGridCellCheckBox)
)
);
pCellCheckBox0->SetAutoTextMode( true );
pCellCheckBox0->Set3StateMode( true );
pCellCheckBox0->SetCheck( 2 ); // indeterminate state
|
|