
Fig1. Illustrates CRecordListCtrl
based on
CListCtrlEx
from this
article.
Introduction
In this article, I present a simple CRecordListCtrlM
to display
the results of a SQL SELECT
operation. Why another similar
grid control? Yeah, you say, many grids are available for VC++ developers, but
this control is small and very useful in MFC applications. Moreover, in
combination with CListCtrlEx
, presented here.
You will find many advanced unique features for developers and end users.
Readers also can replace MFC ODBC classes to MFC DAO. Using ADO or OLE DB
classes is also possible.

Fig2. Illustrates CRecordListCtrl
based on standard
CListCtrl
.
In most cases, all that you need to do is call the following:
m_List.LoadListCtrl(CString aDSN, CString aSQL);
How to Use
Using CRecordListCtrl
is very simple.
- Include the RecordListCtrlEx.h and RecordListCtrlEx.cpp files
in your project.
- If you want to use
CListCtrlEx
in this control instead of
CListCtrl
, just replace with CListCtrlEx
.
Conclusion
By reading this article, you receive two variants for using the
CRecordListCtrl
control. The first is based on
CListCtrl
, providing an easy-to-use way to display SQL SELECT
query results. The second is based on
CListCtrlEx
, and also makes an easy way possible to show the
results of SQL SELECT
and provides a lot of
end-user-friendly functionality. The functions are:
- Multicolumn sorting (working as SQL
ORDER BY
)
- Multicolumn filtering (working as an additional
WHERE
section in SQL SELECT
)
- Column data type auto detection (allows the user input to be more friendly)
- Column coloring and dragging
- Storing/Loading control state
Usage
This software is released into the public domain. You are free to use it in
any way you like. You should save the Author text in the header files. If you
modify it or extend it, please consider posting new code here for everyone to
share. This software is provided "as is" with no expressed or implied warranty.
I accept no liability for any damage or loss of business that this software may
cause.
My special thanks to other authors.