Click here to Skip to main content
15,897,371 members
Articles / Desktop Programming / MFC

CListCtrl and sorting rows

Rate me:
Please Sign up or sign in to vote.
4.43/5 (26 votes)
21 Aug 2008CPOL6 min read 134.6K   6.4K   63  
Examples of how to sort rows in the MFC list control.
// CListCtrl_SortDlg.h : header file
//

#pragma once

#include "CListCtrl_SortItems.h"
#include "CListCtrl_SortItemsEx.h"
#include "CListCtrl_StableSort.h"
#include "CListCtrl_SortStyle.h"
#include "CListCtrl_OwnerData.h"


// CCListCtrl_SortDlg dialog
class CCListCtrl_SortDlg : public CDialog
{
	CListCtrl_DataModel m_DataModel;
	CListCtrl_SortItems m_SortItemsListCtrl;
	CListCtrl_SortItemsEx m_SortItemsExListCtrl;
	CListCtrl_StableSort m_StableSortListCtrl;
	CListCtrl_SortStyle m_SortStyleListCtrl;
	CListCtrl_OwnerData m_OwnerDataListCtrl;

// Construction
public:
	CCListCtrl_SortDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_CLISTCTRL_SORT_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedSortitemsSync();
	afx_msg void OnBnClickedSortitemsExSync();
	afx_msg void OnBnClickedStablesortSync();
	afx_msg void OnBnClickedSortstyleSync();
	afx_msg void OnBnClickedOwnerdataSync();
	afx_msg void OnBnClickedAllSync();
	afx_msg void OnEnKillfocusDatamodelRows();
protected:
	int m_DataModelRows;
	int m_DataModelLookupTime;
public:
	afx_msg void OnEnKillfocusDatamodelLookup();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Denmark Denmark
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions