How can I print a grid that is embedded in a dialog or form view?

Take a look at the formvw1.cpp file in gridapp. The key is to override the printing functions of the form view and delegate them to the grid.

Example:

void CSample1FormView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
   m_wndGrid.OnGridBeginPrinting(pDC, pInfo);
}
void CSample1FormView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
   m_wndGrid.OnGridEndPrinting(pDC, pInfo);
}
void CSample1FormView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
   m_wndGrid.OnGridPrint(pDC, pInfo);
}

void CSample1FormView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo /* = NULL */)
{
   m_wndGrid.OnGridPrepareDC(pDC, pInfo);
}

If you are using the grid in a dialog take a look at the sample that is available in the customer area on our web site. This sample implements a dialog-derivative with printing functionality (NOTE: You need VC version 4.0 or later. The solution does not work for VC 1.5).