Objective Grid: Sorting a CGXBrowserGrid, CGXADOGrid or CGXODBCGrid

Article ID: 264
Last updated: 11 Jun, 2018
Article ID: 264
Last updated: 11 Jun, 2018
Revision: 4
Views: 2141
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


How can I sort a CGXBrowserGrid, CGXAdoGrid or CGXODBCGrid?


Cause



Action


If you want to sort a ADO recordset, you might call (see void CGXAdoGrid::SortRows):

CComPtr<ADORecordset> piRecordset = OnGetRecordset();
piRecordset->put_Sort(CComBSTR(strSort));
Requery();
Redraw();

If you want to sort an ODBC recordset, you might call:

CRecordset* pSet = OnGetRecordset();
pSet->m_strSort = "[GradYear]";
Requery();
Redraw();

If you want to sort other external data sources, you should take a look at the DbfBrows sample (dbfbrvw.cpp). This provides a routine that lets you sort a dbase file or any other grid

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

Others in this category