<< Return to Main Index

< Return to Class Index

CGXControl::LoadStyle

virtual BOOL LoadStyle(ROWCOL nRow, ROWCOL nCol, CGXStyle* pStyle);

nRow

Specifies the row id of the cell.

nCol

Specifies the column id of the cell.

pStyle

A pointer to the existing style information for the cell. You should call ComposeStyleRowCol to gather the style information before you call this method (see example).

Remarks

This method determines the cell-specific style information. By default, the style will not be changed, but the new RTF cell will extract font and alignment from the style value (RTF string) and return them as real style attributes.

Example:

   // check for bold
   CGXStyle styleNeeded;
   styleNeeded.SetBold(TRUE);

   if (GetCurrentCell(nRow, nCol))
   {
      // Cell style (as stored in CGXData)
      CGXStyle style;
      ComposeStyleRowCol(nRow, nCol, &style);

      // Cell-specific style, e.g. RTF will set font and textcolor
      // attributes of the current selection
      CGXControl* pControl = GetRegisteredControl(style.GetControl());
      pControl->LoadStyle(nRow, nCol, &style);

      bRet = style.IsSubSet(styleNeeded);
   }

   // bRet will be TRUE if the caret or the cell is bold

If the current cell is a RichEdit control and owns the focus, the call to LoadStyle will determine the font and alignment attributes for the current caret position. You may check this behavior out by running the RTFGrid sample and clicking into bold or non-bold text. The toolbar buttons will reflect the current settings under the caret.

See Also

CGXControl::StoreStyle CGXGridCore::ComposeStyleRowCol CGXRichEditCtrl

CGXControl

Class Overview | Class Members