<< Return to Main Index

< Return to Class Index

CGXGridCore::ChangeBaseStyle

virtual BOOL ChangeBaseStyle(WORD wStyleID, const CGXStyle& style, GXModifyType mt = gxOverride, UINT nFlags = GX_UPDATENOW, GXCmdType ctCmd = gxDo);

wStyleID

Specifies a unique id for a registered base-style.

style

A reference to a style-object which should be applied to the base-style.

mt

Modify-Type: gxOverride, gxApplyNew, gxCopy or gxExclude (see CGXStyle::ChangeStyle).

nFlags

GX_INVALIDATE - invalidates the window

ctCmd

Specifies if the executed command is undone (gxUndo), redone (gxRedo), executed the first time (gxDo) or rolled back (gxRollback).

Return Value

TRUE if the command has been successfully executed; it is FALSE if the command failed.

Remarks

Lets you change the settings of the specified base-style.

It is recommended that you call ChangeBaseStyle instead of getting a reference to the base-style object with BaseStyle and changing that style directly (as you did with Objective Grid 1.x).

Notes about Compatibility with Version 1.x

If you are changing the base-style object while you are initializing the grid, there is no problem with changing base-styles directly. There is no need to change your existing code and rewrite OnInitialUpdate or OnInitDialog routines.

But if you are changing base-style settings after the grid has been initialized, it is necessary that you call ChangeBaseStyle. Otherwise, the grid is not notified about changes in the base-style object, and therefore internal settings will not be updated immediately.

For example, changing the font of the standard-style forces the grid to recalculate all floating cells. But, if you modify the standard-style object directly with StandardStyle().SetFont(…), the grid is not notified about the font change and will therefore not recalculate the floating cells.

Benefits of using ChangeBaseStyle are:

Note: Don’t call this method before you have attached a parameter and stylesmap object to the grid. Otherwise, the function will assert.

Example:

If you have registered a base-style with

static TCHAR BASED_CODE szMyStyle[] = _T("MyStyle");
WORD m_nMyStyle;

      // "My Style" - A style with a combo box and choice list as default
      CGXStylesMap* pStylesMap = GetParam()->GetStylesMap();
      m_nMyStyle = pStylesMap->RegisterStyle(szMyStyle,
            CGXStyle()
               .SetControl(GX_IDS_CTRL_CBS_DROPDOWNLIST)
               .SetChoiceList(_T("one\r\ntwo\r\nthree\r\nfour\r\nfive\r\nsix\r\n")),
            TRUE    // system-style (non removable)
         );

you can later change that style with

      ChangeBaseStyle(m_nMyStyle, CGXStyle()
         .SetFont( CGXFont()
            .SetFaceName(_T("Times New Roman"))
            .SetSize(9) )
         );

See Also

CGXGridCore::BaseStyle CGXGridCore::ChangeStandardStyle CGXGridCore::ChangeRowHeaderStyle CGXGridCore::ChangeColHeaderStyle CGXStylesMap::RegisterStyle

CGXGridCore

Class Overview | Class Members