<< Return to Main Index

< Return to Class Index

CGXAbstractControlFactory::CreateControl

virtual CGXControl* CreateControl(UINT nID, CGXGridCore* pGrid) = 0;

nID

Specifies the control id (same as CGXStyle::GetControl)

pGrid

Points to the parent grid.

Return Value

A pointer to the allocated control object.

Remarks

CreateControl is called to instantiate a specific cell type as child of the given grid. In your override of CreateControl, you should check nID to determine which control to instantiate. This is best done with a switch statement.

Please note that some control require additional initialization steps beyond simple construction before the control pointer can be returned.  Please refer to the code in Src\Grid\gxfactry.cpp for any additional initialization steps.

Example

The following sample code shows a typical case statement for control instantiation.

CGXControl* CGXControlFactory::CreateControl(UINT nID,

CGXGridCore* pGrid)

{

CGXControl* pControl = NULL;

// Create control on demand

switch (nID)

{

case GX_IDS_CTRL_EDIT:

// Default edit box

pControl = new CGXEditControl(pGrid, GX_IDS_CTRL_EDIT);

break;

case GX_IDS_CTRL_HEADER:

// default headers

pControl = new CGXHeader(pGrid);

break;

}

return pControl;

}

See Also

CGXStyle::GetControl CGXGridCore::GetRegisteredControl

CGXAbstractControlFactory

Class Overview | Class Members