How Do i print the Total Grid Columns In single page By rotating the grid into horizontal when printing the page ???
When AM Printing My Grid it displaying in two pages but i want total grid in single page when printing.
code:
public void ShowPrintButtons()
{
if (this.dgvODReport.RowCount >= 1)
{
btnPrint.Visible = true;
btnPrintPreview.Visible = true;
}
else
{
btnPrint.Visible = false;
btnPrintPreview.Visible = false;
}
}
private bool SetupThePrinting()
{
PrintDialog MyPrintDialog = new PrintDialog();
MyPrintDialog.AllowCurrentPage = false;
MyPrintDialog.AllowPrintToFile = false;
MyPrintDialog.AllowSelection = false;
MyPrintDialog.AllowSomePages = false;
MyPrintDialog.PrintToFile = false;
MyPrintDialog.ShowHelp = false;
MyPrintDialog.ShowNetwork = false;
if (MyPrintDialog.ShowDialog() != DialogResult.OK)
return false;
MyPrintDocument.DocumentName = "OD Report";
MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
MyPrintDocument.DefaultPageSettings.Margins = new Margins();
PaperSize paperSize = new PaperSize("Super B", 1100, 820);
paperSize.RawKind = (int)PaperKind.Custom;
MyPrintDocument.DefaultPageSettings.Landscape = true;
MyPrintDocument.DefaultPageSettings.Margins = new Margins(0, 00, 0, 0);
if (MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
MyDataGridViewPrinter = new DataGridViewPrinter(dgvODReport, MyPrintDocument, true, true," " + dtptodaydate.Value.ToString("MMMM") + "", new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
else
MyDataGridViewPrinter = new DataGridViewPrinter(dgvODReport, MyPrintDocument, true, true,"", "" + dtptodaydate.Value.ToString("MMMM") + "", new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
return true;
}
private void btnPrint_Click(object sender, EventArgs e)
{
if (SetupThePrinting())
MyPrintDocument.Print();
}
private void btnPrintPreview_Click(object sender, EventArgs e)
{
if (SetupThePrinting())
{
PrintPreviewDialog MyPrintPreviewDialog = new PrintPreviewDialog();
MyPrintPreviewDialog.Document = MyPrintDocument;
MyPrintPreviewDialog.ShowDialog();
}
}
private void MyPrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
bool more = MyDataGridViewPrinter.DrawDataGridView(e.Graphics);
if (more == true)
e.HasMorePages = true;
}