Objective Grid: How should I fill the grid with values?

Article ID: 206
Last updated: 04 Jun, 2018
Article ID: 206
Last updated: 04 Jun, 2018
Revision: 3
Views: 2290
Posted: 11 Jan, 2001
by Meltreger B.
Updated: 04 Jun, 2018
by Meltreger B.

Problem


How should I fill the grid with values?


Cause



Action


SetValueRange() and SetStyleRange() let you change cell values and formatting. It is recommended that you call LockUpdate(TRUE) before you do several SetValueRange() calls. Upon initialization of the grid, you should also turn off undo creation.

Example:
 

// turn off undo creation, prevent updating the grid
GetParam()->EnableUndo(FALSE);
BOOL bOldLock = LockUpdate(TRUE);

// specify the dimension of the grid
SetRowCount(nRows);
SetColCount(nCols);

// fill cell values
for (...)
{

CString str;
double d;
CGXStyle style;

SetValueRange(CGXRange(nRow, 1), str); // string
SetValueRange(CGXRange(nRow, 2), d); // number

// you can also use SetStyleRange to apply values
SetStyleRange(CGXRange(nRow, 3), style.SetValue(str));

// apply a value together with text color
SetStyleRange(CGXRange(nRow, 4), style

.SetValue(str)
.SetTextColor(RGB(255, 0, 0));
}

// enable updating the grid and undo creation
LockUpdate(bOldLock);
GetParam()->EnableUndo(TRUE);

// Redraw the grid
Redraw();

See also the 1stGrid tutorial in ogguide.doc.
 

This article was:   Helpful | Not helpful
Report an issue
Article ID: 206
Last updated: 04 Jun, 2018
Revision: 3
Views: 2290
Posted: 11 Jan, 2001 by Meltreger B.
Updated: 04 Jun, 2018 by Meltreger B.

Others in this category