Reputation: 71
How can I set the print Preview and print code to landscape orientation ?
this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.ClientSize = new System.Drawing.Size(700, 600);
this.printPreviewDialog1.Document = this.printDocument1;
this.printPreviewDialog1.Enabled = true;
this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
this.printPreviewDialog1.Name = "printPreviewDialog1";
this.printPreviewDialog1.Visible = false;
//
// printDocument1
//
this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage_1);
Upvotes: 1
Views: 8032
Reputation:
This works for me
private void button_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printDocument1.DefaultPageSettings.Landscape = true;
printPreviewDialog1.ShowDialog();
}
Upvotes: 0
Reputation: 71
This did the trick
this.printDocument1.DefaultPageSettings.Landscape = true;
Upvotes: 4
Reputation: 8043
Won't this
var doc = new PrintDocument();
doc.DefaultPageSettings.Landscape = true;
do the trick?
It will probably take care of the print preview issue as well.
Upvotes: 0