Objective Grid: Using a grid in a dialog

Article ID: 99
Last updated: 22 Jun, 2018
Article ID: 99
Last updated: 22 Jun, 2018
Revision: 3
Views: 2338
Posted: 09 Jan, 2001
by Meltreger B.
Updated: 22 Jun, 2018
by Meltreger B.

Problem


How can I use a grid in a dialog?


Cause



Action


The following steps are necessary to embed a grid in a dialog.

  1. Create or open your dialog template. Choose the user control icon, drag it into the the dialog and open its property page. Enter "GXWND" as class name into the class box and specify the style bits for the grid:
  • 0x50b10000 to display both scrollbars and a border
  • 0x50810000 to display no scrollbars but a border

See the definitions for windows style bits in your windows.h header file.

  1. If you created a new dialog, you should now create your dialog class with ClassWizard.
  2. Embed an object of your derived grid class in the dialog.

class CDerGridDialog : public Cdialog
{
// Construction
public:
CDerGridDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
CMyGridWnd m_wndGrid;

...

  1. Add the OnInitDialog member to your dialog class (WM_INITDIALOG-message). In OnInitDialog, you can initialize the grid:
BOOL CDerGridDialog::OnInitDialog( )
{
CDialog::OnInitDialog( );
m_wndGrid.SubclassDlgItem(IDC_GRIDSAMPLE, this);
m_wndGrid.Initialize( );

...

Note: If you want to use the grid in a formview, you should override OnInitialUpdate instead of OnInitDialog.

  1. In the dialog's DoDataExchange method add:
DDV_GXGridWnd(pDX, &m_wndGrid);

This article was:   Helpful | Not helpful
Report an issue
Article ID: 99
Last updated: 22 Jun, 2018
Revision: 3
Views: 2338
Posted: 09 Jan, 2001 by Meltreger B.
Updated: 22 Jun, 2018 by Meltreger B.

Others in this category