Objective Grid: Inserting unbound columns

Article ID: 335
Last updated: 07 Jun, 2018
Article ID: 335
Last updated: 07 Jun, 2018
Revision: 3
Views: 2058
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 07 Jun, 2018
by Meltreger B.

Problem


How can I insert unbound columns where I want to display some additional info based on existing columns?


Cause



Action


You can insert columns with

InsertCols(3, 1);

and override OnLoadCellStyle(). In OnLoadCellStyle() you can determine the values of the neighboring columns with GetValueRowCol(nRow, nCol).

Example:

BOOL CDaoqueryView::OnLoadCellStyle(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, LPCTSTR pszExistingValue)
{
// Is this the new column for the expression?
if (nCol == 3)
{
double val1 = GetValueRowCol(nRow, 1);
double val2 = GetValueRowCol(nRow, 2);

// Compute value
style.SetValue(val1+val2);

// Don't let the user change
// the value, make it static
style.SetControl(GX_IDS_CTRL_STATIC);

return TRUE;

}

// Let the CGXDAOGrid read all
// other columns from recordset

return CGXDaoRecordView::OnLoadCellStyle(nRow, nCol, style, pszExistingValue);

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 335
Last updated: 07 Jun, 2018
Revision: 3
Views: 2058
Posted: 24 Jan, 2001 by Meltreger B.
Updated: 07 Jun, 2018 by Meltreger B.

Others in this category