Objective Grid: Support for Number Formats in ODBC grids

Article ID: 688
Last updated: 11 Jun, 2018
Article ID: 688
Last updated: 11 Jun, 2018
Revision: 3
Views: 1681
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


Number formatting for numeric columns in ODBC grids.
 


Cause


Objective Grid currently does not provide support for Number Format (CGXStyle::SetFormat) with ODBC grids, but you can easily add support for that on your own.
 


Action


Override the following method in your view.
 

BOOL CGxqueryView::OnLoadCellStyle(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, LPCTSTR pszExistingValue)
{
BOOL bRet = CMyRecordView::OnLoadCellStyle(nRow, nCol, style, pszExistingValue);

if (style.GetIncludeValue())
{

int nField = GetFieldFromCol(nCol);
CRecordset* pRecordset = OnGetRecordset();
#if _MFC_VER >= 0x0420
CGXFieldInfo& ci = GetDbParam()->m_apFieldInfo[nField];

switch (ci.nDataType)

#else
CFieldInfo ci;
pRecordset->GetFieldInfo(nField, &ci);

switch (ci.nDataType)

#endif
{
case AFX_RFX_BOOL:
case AFX_RFX_BYTE:
case AFX_RFX_INT:
case AFX_RFX_LONG:
case AFX_RFX_SINGLE:
case AFX_RFX_DOUBLE:
style.SetValueType(GX_VT_NUMERIC);
break;
}
}

return bRet;

}

That will make sure that numeric values are not considered as strings. We will add support for that in future OG versions.

Adding support for number formatting in a ADO Grid should work similarly.
 
 

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

Others in this category