Domanda

I want to print the currently active WinForm in C#. Here is what I have:

using Microsoft.VisualBasic.PowerPacks.Printing;

PrintForm p = new PrintForm(this);
p.Print();

This works great for portrait mode. How can I print in landscape mode?

È stato utile?

Soluzione

Does this work?

PrintForm p = new PrintForm(this);
p.PrinterSettings.DefaultPageSettings.Landscape = true;
p.Print();

Altri suggerimenti

if you are doing this in VB then you want to look at Orientation as an example

if it's C# I am sure you can do the conversion

If p.Height > p.Width 
{
    p.Orientation = 1;//vbPRORPortrait
}
Else
{
    p.Orientation = 2; //vbPRORLandscape
}
p.Print();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top