void SetParam(CGXGridParam* pParam, BOOL bMustDelete = TRUE);?
pParam
A pointer to the parameter-object.
bMustDelete
Specifies if the object is lifetime bound to the grid (i.e., if it should be destroyed when the grid is closed).
Sets a pointer for the parameter-object and defines if the object should be lifetime bound to the grid.
If you allocate the parameter-object on the heap, you should set bMustDelete to TRUE. On the other hand, if you have embeded the parameter-object in the document, you should set bMustDelete to FALSE.
If you do not explicitly call SetParam in an overridden OnInitialUpdate-method, CGXGridCore::OnGridInitialUpdate will allocate a parameter-object on the heap and attach it to the grid.
If the grid already owns a pointer to a parameter-object, the old parameter-object is replaced with the new one. If you are re-initializing the grid with a new parameter-object then you should call CGXGridView::OnInitialUpdate (or CGXGridWnd::Initialize) to re-initialize the grid properly, followed by your custom initialization like setting the styles etc.(if necessary). You could enclose your re-initialization code within LockUpdate(TRUE) and LockUpdate(FALSE) calls to prevent flicker and finally call Redraw.
The examples show the main scenarios for attaching a parameter-object to the grid.
Example 1 illustrates how to allocate the parameter-object on the heap when using a stand-alone grid-view or -window.
CGXSampleView::OnInitialUpdate( )
{
ASSERT(GetParam( ) == NULL);
SetParam(new CGXGridParam);
ASSERT(GetParam( ) != NULL); // Now, there must be a parameter-object
// Now, you can attach the properties-, the stylesmap-
// and the data-object to the parameter-object
...
CGXGridView::OnInitialUpdate( );
ASSERT(GetParam( )->GetData( )); // Data object must exist
ASSERT(GetParam( )->GetProperties( )); // Properties-object exists
ASSERT(GetParam( )->GetStylesMap( )); // Stylesmap-object exists
GetParam( )->EnableUndo(FALSE); // turn off creation of undo-information
SetRowCount(...);
...
GetParam( )->EnableUndo(TRUE); // turn on creation of undo-information
SetModifiedFlag(FALSE);
}
Example 2 illustrates how to link the grid-view to a document.
CGXSampleView::OnInitialUpdate( )
{
ASSERT(GetParam( ) == NULL);
SetParam(&GetDocument( )->m_param, FALSE /* do not destroy */);
ASSERT(GetParam( ) != NULL); // Now, there must be a parameter-object
// Now, you can attach the properties-, the stylesmap-
// and the data-object to the parameter-object
...
CGXGridView::OnInitialUpdate( );
EnableHints( ); // Enable creation of hints
ASSERT(GetParam( )->GetData( )); // Data object must exist
ASSERT(GetParam( )->GetProperties( )); // Properties-object exists
ASSERT(GetParam( )->GetStylesMap( )); // Stylesmap-object exists
GetParam( )->EnableUndo(FALSE); // turn off creation of undo-information
SetRowCount(...);
...
GetParam( )->EnableUndo(TRUE); // turn on creation of undo-information
SetModifiedFlag(FALSE);
}
More examples are:
CGXGridCore::GetParam CGXGridParam
class CMyView::public CGXGridView
{
CGXGridParam m_param;
...
}
Class Overview | Class Members