<< Return to Main Index

< Return to Class Index

CGXGridCore::SetValueRange

BOOL SetValueRange(const CGXRange& range, const CString& str, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, LPCTSTR lpsz, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, const char* lpsz, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, DWORD dw, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, WORD w, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, short s, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, LONG l, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, float f, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

BOOL SetValueRange(const CGXRange& range, double d, GXModifyType mt = gxOverride, int nType = 0, UINT flags = GX_UPDATENOW);

range

A reference to a range-object specifying the cells to be changed. A range can be a range of cells, a range of rows, a range of columns or the whole table. (See the CGXRange class)

str

Specifies the text to be used as value with a reference to a CString.

lpsz

Specifies the text to be used as value. If you pass a const char* in UNICODE builds, the string will be converted to wide characters.

dw

A DWORD value.

w

A WORD value.

s

A short value.

l

A LONG value.

f

A float value.

d

A double value.

nType

Specifies the type of information to be set:

mt

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

flags

Specifies the update technique. See UpdateStyleRange for more information.

Return Value

TRUE if the command has been successfully executed; it is FALSE if the command failed or if the user aborted the operation.

If you do a series of commands, you should check the return value and abort your operation (or rollback the transaction) if the return value is FALSE.

Remarks

Call this method if you want to change the value for a cell or a range of cells.

If called with nType = GX_VALUE_EXPRESSION the style value will be interpreted (by calling SetExpressionRowCol). Otherwise the style value will be assigned to the cell as text label (by calling SetTextRowCol).

The value will always be stored as string in the CGXStyle object but the ValueType will be set appropriately to GX_VT_NUMERIC for the numeric SetValue version or GX_VT_STRING for the string version.

The values are stored by internally calling the command SetStyleRange.

When you are using the formula engine and a style object is passed to the engine, the engine will either store a number or a string based of the ValueType information. The formula engine stores values directly as double or as string.

Note

If you make a series of subsequent calls to SetValueRange (e.g., when filling a grid), you should first call LockUpdate(TRUE) to prevent updating the grid each time SetValueRange is called. Updating the grid each time requires computing window coordinates, invalidating the area and redrawing the cells (and will slow down performance substantially). After applying the values to the cells, you should call LockUpdate(FALSE) and redraw the cells with RedrawRowCol or Redraw (see the description of LockUpdate for further details).

Example 2 illustrates how to use LockUpdate.

Example

These examples illustrate the usage of the SetValueRange method:

Example 1 sets the value for a cell.

   SetValueRange(CGXRange(nRow, nCol), 1));
   SetValueRange(CGXRange(nRow, nCol+1), "2");

Example 2 illustrates how to do a series of SetValueRange commands.

   BOOL bLockOld = LockUpdate(TRUE);
   for (ROWCOL nCol = 1; nCol < 10; nCol++)
   {
      for (ROWCOL nRow = 1; nRow < 10; nRow++)
      {
         SetValueRange(CGXRange(nRow, nCol), nCol*10+nRow);
      }
   }
   LockUpdate(bLockOld);
   RedrawRowCol(1, 1, 10, 10);

See Also

CGXGridCore::SetStyleRange CGXGridCore::UpdateStyleRange CGXGridCore::LockUpdate CGXRange CGXStyle::ChangeStyle CGXGridCore::SetExpressionRowCol

CGXGridCore

Class Overview | Class Members