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 » Notification on events in CExtGridWnd Collapse All
Subject Author Date
Andreas Werner Nov 14, 2006 - 6:27 AM

Hallo,
I am using the CExtGridWnd class to create a list with a nice layout for each line. To make the grid look like a list I use the __EGBS_SFB_FULL_ROWS style and I don’t draw the vertical grid lines. I can give the grid the look I need according to demonstration in your Prof-UIS Controls example. Now I have the grid but I don’t understand the concepts how to get notifications on the user’s interaction with grid. I have three problems now:

I am using CExtGridCellWnd with cells of the type CExtGridCellBool. What is the best way to get notifications if a checkbox of the boolen cell gets checked or unchecked?
I have tried to subclass CExtGridCellBool and overwrite OnSetCheck but I don’t get it working to create an instance of my own GridCellBool in the grid window.

I would also need a notification if the user selects a row in the grid. What is the best way to a notification if a row is selected?

How can I show a context menu if the user performs a right click on a row in the grid?

With best regards Andreas

Suhai Gyorgy Nov 14, 2006 - 9:35 AM

SimpleGrid sample shows the way to "get notifications". You’ve been going to the right direction with subclassing, but it’s a little different with CExtGridWnd. You have to make a CExtGridCellBool-derived class and override the methods you need (in your case it’s DataSet). But take care the have these in your new cell class’s declaration (copied from SimpleGrids sample):

	DECLARE_DYNCREATE( CDemoComboCell );
	IMPLEMENT_ExtGridCell_Clone( CDemoComboCell, CExtGridCellStringDM );
	CDemoComboCell(
		CExtGridDataProvider * pDP = NULL
		);
and also in .cpp, right after the includes:
// moved to top (i.e. before DEBUG_NEW) to avoid
// conflict with MFC’s operator new
IMPLEMENT_DYNCREATE( CDemoComboCell, CExtGridCellStringDM );
...
  
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
and the definition:
CDemoColoredCell::CDemoColoredCell(
	CExtGridDataProvider * pDP // = NULL
	)
	: CExtGridCellStringDM( pDP )
{
}
The way you can use your class instead of CExtGridCellBool: you should use a code similar to this when initializing your grid:
		CDemoComboCell * pCellString =
			STATIC_DOWNCAST(
				CDemoComboCell,
				GridCellGet(
					1L,
					nRowNo,
					0,
					0,
					RUNTIME_CLASS(CDemoComboCell)
					)
				);

Andreas Werner Nov 15, 2006 - 1:25 AM

Hallo,

thank You for the information. I had trouble to get the macros in the right place but now it is working. I am overwritng the OnSetCheck method of the CExtGridCell class because it provides informtion about the row and the column where the check change happend.

With best regards Andreas

Technical Support Nov 17, 2006 - 12:11 PM