How can I insert unbound columns where I want to display some additional info based on existing columns?
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);
}