MFC Grid manual

How to create a grid in SDI/MDI application?

How to create a grid:
class CDemoView : public CView
{
  ...
     afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
     afx_msg void OnSize(UINT nType, int cx, int cy);
  private:
     Dapfor::GUI::CGrid m_Grid;
};

int CDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   ...
   //Initialize the grid
   m_Grid.Create(0, 0, WS_VISIBLE|WS_CHILD, CRect(), this, 1000);
  
   //Create a header:
   Dapfor::GUI::CHeader* header = new Dapfor::GUI::CHeader(true);

   //Add some columns to header. Field identifiers should be the same as declared in the data object
   //For more information see "How to install my first application"
   header->Add(new Dapfor::GUI::CColumn(CDemoClass::FidPrice,  _T("Field1"), 190));

   //Set header for the grid     
   m_Grid.SetHeader(header);

   ...
   return 0;
}

void CDemoView::OnSize(UINT nType, int cx, int cy) 
{
    CMDIChildWnd::OnSize(nType, cx, cy);

    //Fit the grid to client area
    CRect rc;
    GetClientRect(rc);
    m_Grid.MoveWindow(rc);
}


//Declaration of a C++ class:
 class CDemoClass : public Common::CDataObject
 {
 public:
     enum 
     {
        FidPrice,
     };
     ...
     double GetPrice() const;
     ...
 };

 //This code adds C++ objects to the grid:
 CDemoClass* obj = new CDemoClass();
 m_Grid.Add(obj);