Sorting problem with CGXCurrencyEdit and decimal separators

Article ID: 301
Last updated: 11 Jun, 2018
Article ID: 301
Last updated: 11 Jun, 2018
Revision: 3
Views: 1811
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


A column of CGXCurrencyEdit controls does not sort properly if the controls use a comma as the decimal separator


Cause


This is a bug.


Action


The problem is in CGXCurrencyEdit::GetSortKey(). In this function, if sKey has a fractional part, we need to replace '.' with the decimal separator before parsing.

 
void CGXCurrencyEdit::GetSortKey(ROWCOL nRow, ROWCOL nCol, const CGXSortInfo& sortInfo, const CGXStyle& style, CString& sKey)
{
	? ?

	InitFromUserAttributes(&m_CapCtrlWnd, &style);
	Format f;
	double d;
	m_CapCtrlWnd.GetFormat(f);

	int nPos = sKey.Find('.');
	if(nPos!=-1)
	    sKey.SetAt(nPos,f.GetDecimalSeparator());

	? ?

}

If you do not want to change the Objective Grid source code, you can subclass CGXCurrencyEdit and override its virtual method GetSortKey() as given above.

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

Others in this category