Sdílet prostřednictvím


PrintDocument.DefaultPageSettings Vlastnost

Definice

Získá nebo nastaví nastavení stránky, které se používají jako výchozí hodnoty pro tisk všech stránek.

public:
 property System::Drawing::Printing::PageSettings ^ DefaultPageSettings { System::Drawing::Printing::PageSettings ^ get(); void set(System::Drawing::Printing::PageSettings ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Printing.PageSettings DefaultPageSettings { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DefaultPageSettings : System.Drawing.Printing.PageSettings with get, set
Public Property DefaultPageSettings As PageSettings

Hodnota vlastnosti

A PageSettings , která určuje výchozí nastavení stránky dokumentu.

Atributy

Příklady

Následující příklad kódu nastaví orientaci stránky dokumentu na šířku a vytiskne dokument. Příklad provádí tři předpoklady: že proměnná s názvem filePath byla nastavena na cestu k souboru k tisku; že byla definována metoda s názvem pd_PrintPage, která zpracovává PrintPage událost, a že proměnná s názvem printer byla nastavena na název tiskárny.

V tomto příkladu System.Drawingpoužijte obory názvů , System.Drawing.Printinga System.IO obory názvů.

public:
   void Printing()
   {
      try
      {
         streamToPrint = gcnew StreamReader( filePath );
         try
         {
            printFont = gcnew System::Drawing::Font( "Arial",10 );
            PrintDocument^ pd = gcnew PrintDocument;
            pd->PrintPage += gcnew PrintPageEventHandler(
               this, &Form1::pd_PrintPage );
            pd->PrinterSettings->PrinterName = printer;
            // Set the page orientation to landscape.
            pd->DefaultPageSettings->Landscape = true;
            pd->Print();
         }
         finally
         {
            streamToPrint->Close();
         }
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( ex->Message );
      }
   }
public void Printing()
{
   try
   {
      streamToPrint = new StreamReader (filePath);
      try
      {
         printFont = new Font("Arial", 10);
         PrintDocument pd = new PrintDocument(); 
         pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
         pd.PrinterSettings.PrinterName = printer;
         // Set the page orientation to landscape.
         pd.DefaultPageSettings.Landscape = true;
         pd.Print();
      } 
      finally
      {
         streamToPrint.Close() ;
      }
   } 
   catch(Exception ex)
   { 
      MessageBox.Show(ex.Message);
   }
}
Public Sub Printing()
    Try
        streamToPrint = New StreamReader(filePath)
        Try
            printFont = New Font("Arial", 10)
            Dim pd As New PrintDocument()
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            pd.PrinterSettings.PrinterName = printer
            ' Set the page orientation to landscape.
            pd.DefaultPageSettings.Landscape = True
            pd.Print()
        Finally
            streamToPrint.Close()
        End Try
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

Poznámky

Prostřednictvím vlastnosti můžete zadat několik výchozích nastavení DefaultPageSettings stránky. Vlastnost například určuje, PageSettings.Color zda se stránka vytiskne barvou, PageSettings.Landscape vlastnost určuje orientaci na šířku nebo na výšku a PageSettings.Margins vlastnost určuje okraje stránky.

Chcete-li zadat nastavení na stránce po stránkách, zpracujte PrintPage událost nebo QueryPageSettings událost a upravte PageSettings argument zahrnutý v objektu PrintPageEventArgs nebo QueryPageSettingsEventArgs, v uvedeném pořadí.

Poznámka:

Po spuštění tisku nebudou změny nastavení stránky prostřednictvím DefaultPageSettings vlastnosti mít vliv na vytištěné stránky.

Platí pro

Viz také