CGXGridCore::SetParam

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).

Remarks

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

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:

See Also

 CGXGridCore::GetParam  CGXGridParam

  • Embed a parameter-object in your grid-view class.
   class CMyView::public CGXGridView
   {
      CGXGridParam m_param;
      ...
   }
  • attach it to the grid as shown in Example 2.

  • Embed a CObArray in your document and maintain several parameter-objects in the document. See the CGridSampleDoc class in the GridApp sample application which maintains a workbook with several grid-views as worksheets. You also have to take care of assigning each view a unique m_nViewID.

CGXGridCore

 Class Overview |  Class Members