|
1. Create a dialog-based Application.
2. Configure the application as shown in How to install the MFC grid and compile the first application?
3. Open the Controls Panel, select there the Custom Control and put this control on the dalog form. Then, in the 'Custom Control Properties' window in the 'Class' edit box tape Dapfor.Grid as shown below:
4. Add a member of CGrid to the dialog
//DialogApplicationDlg.h file #pragma once #include <Dapfor/GUI/Grid.h> //Declaration of the dialog class class CDialogApplicationDlg : public CDialog { ... protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support private: Dapfor::GUI::CGrid m_Grid; //The grid will register the window class name 'Dapfor.Grid' in the constructor. };
5. Implement the DoDataExchange mechanism for the grid control
void CDialogApplicationDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDialogApplicationDlg) DDX_Control(pDX, IDC_CUSTOM_GRID, m_Grid); //}}AFX_DATA_MAP }
6. The dialog is ready. Now you can add some columns to the header and configure the grid in the OnInitDialog() handler.
BOOL CDialogApplicationDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//The grid should be initialized here after the DDX exchange.
//Now, let's create a header and add some columns
Dapfor::GUI::CHeader* header = new Dapfor::GUI::CHeader(true);
header->Add(new Dapfor::GUI::CColumn(CTestClass::FidName, "Name", 100));
//Set the header to the grid
m_Grid.SetHeader(header);
return TRUE;
}
| Copyright Dapfor 2007-2009 | Generated on Sat Jan 30 15:01:23 2010 for MFCGrid by 1.5.5 |