Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

CGridCtrl with Merge Cell and Freeze Row/Col Capability

Rate me:
Please Sign up or sign in to vote.
4.83/5 (29 votes)
18 Aug 2010CPOL7 min read 88.4K   5.7K   59  
Add XL style merge cell as well as Freeze Pane (freeze row/col) functionality to Chris Maunder's CGridCtrl.
// GridCtrlTestDlg.h : header file
//

#pragma once
#include "gridctrl_src\gridctrl.h"
#include "afxwin.h"


// CGridCtrlTestDlg dialog
class CGridCtrlTestDlg : public CDialog
{
// Construction
public:
	CGridCtrlTestDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_GRIDCTRLTEST_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:
	CGridCtrl m_grid;

public:
	afx_msg void OnBnClickedButtonMerge();
	afx_msg void OnBnClickedButtonFreeze();

public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedCancel();

public:	
	CEdit m_editRowCount;
	CEdit m_editColCount;

protected:
	virtual BOOL PreTranslateMessage(MSG* pMsg);	
public:
	CEdit m_editFreezedRows;
	CEdit m_editFreezedCols;
	CEdit m_editMinRow;
	CEdit m_editMaxRow;
	CEdit m_editMinCol;
	CEdit m_editMaxCol;
	afx_msg void OnBnClickedButtonUnmerge();
	afx_msg void OnBnClickedButtonColcount();
	afx_msg void OnBnClickedButtonRowcount();
};

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
Technical Lead Kotha Technologies
Bangladesh Bangladesh
If you are not in - you are out !
- Chapter 1

Comments and Discussions