CGXStyle::SetBaseStyle

CGXStyle& SetBaseStyle(WORD wStyle);

wStyle

Specifies the base style.

Return Value

Returns the this pointer.

Remarks

Specifies the base style.

Base styles contain default settings for a certain group of cells.

Objective Grid provides three pre-defined base styles:

  • StandardStyle – contains default settings for any cell

  • RowHeaderStyle – contains default setting for row headers

  • ColHeaderStyle – contains default settings for column headers

You can change any of the above named style objects with the ChangeStandardStyle, ChangeRowHeaderStyle and ChangeColHeaderStyle API.

Objective Grid lets you add your own base styles and apply these base styles to cells. This gives you a very powerfull way to define the appearance for a group of cells and also let the end-user modify the appearance of these cells through the style sheet dialog. You can check this out in the gridapp sample with the menu item Format|Styles.

Suppose you are displaying some data in a grid and you want to outline values that are lower or higher than normal. You can define that all values that are below zero should have a blue text color and and all values that are higher than 100 should have a red text color. The user can change these default settings to his needs. Maybe the user prefers to have a red background color with yellow text instead of red text.

You need to register a base style first, before you can use it in styles. See CGXStylesMap::RegisterStyle.

To apply base styles to cells you first have to get an id for the base style.

Example:

   m_wStyleCombo = GetParam()->GetStylesMap()->GetBaseStyleId(szComboStyle);
   m_wStyleError = GetParam()->GetStylesMap()->GetBaseStyleId(szErrorStyle);
      SetStyleRange(
         CGXRange(5,2,8,3),
         CGXStyle()
            .SetBaseStyle(m_wStyleCombo)
            .SetValue(_T("one"))
         );
      SetStyleRange(
         CGXRange(5,4,8,5),
         CGXStyle()
            .SetBaseStyle(m_wStyleError)
            .SetValue(_T("ALERT!"))
         );

See Also

 CGXStylesMap  CGXStylesMap::GetBaseStyleId  CGXStylesMap::RegisterStyle

CGXStyle

 Class Overview |  Class Members