Create Your Print Document
System::Drawing::Printing::PrintDocument ^printDoc;
Start Printing
//Setup the print dialog
PrintDialog ^dlgPrint = gcnew PrintDialog();
dlgPrint->AllowSelection = true;
dlgPrint->ShowNetwork = true;
dlgPrint->Document = printDoc;
dlgPrint->PrinterSettings->DefaultPageSettings->Landscape = true; //(This doesn't necessarily work)
dlgPrint->UseEXDialog = true;
printDoc->BeginPrint += gcnew System::Drawing::Printing::PrintEventHandler(this, &DataGridViewPrint::PrintDoc_BeginPrint);
printDoc->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler(this, &DataGridViewPrint::PrintDoc_PrintPage);
if (dlgPrint->ShowDialog() != DialogResult::OK)
{
printDoc->BeginPrint -= gcnew System::Drawing::Printing::PrintEventHandler(this, &DataGridViewPrint::PrintDoc_BeginPrint);
printDoc->PrintPage -= gcnew System::Drawing::Printing::PrintPageEventHandler(this, &DataGridViewPrint::PrintDoc_PrintPage);
return;
}
//Print the Documnet
printDoc->Print();
printDoc->BeginPrint -= gcnew System::Drawing::Printing::PrintEventHandler(this, &DataGridViewPrint::PrintDoc_BeginPrint);
printDoc->PrintPage -= gcnew System::Drawing::Printing::PrintPageEventHandler(this, &DataGridViewPrint::PrintDoc_PrintPage);
The Callbacks To Provide
void DataGridViewPrint::PrintDoc_BeginPrint(System::Object^ sender, System::Drawing::Printing::PrintEventArgs ^e)
{
}
void DataGridViewPrint::PrintDoc_PrintPage(System::Object ^sender, System::Drawing::Printing::PrintPageEventArgs ^e)
{
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.