Aracılığıyla paylaş


PrintPageEventArgs.HasMorePages Özellik

Tanım

Ek bir sayfanın yazdırılıp yazdırılmayacağını belirten bir değer alır veya ayarlar.

public:
 property bool HasMorePages { bool get(); void set(bool value); };
public bool HasMorePages { get; set; }
member this.HasMorePages : bool with get, set
Public Property HasMorePages As Boolean

Özellik Değeri

true ek bir sayfa yazdırılması gerekiyorsa; aksi takdirde , false. Varsayılan değer: false.

Örnekler

Aşağıdaki kod örneği, üzerinde Formbir Button adlandırılmış printButton ve bir PrintDocument adlandırılmış pd oluşturulduğunu varsayar. için Button olayının Click yöntemiyle ilişkilendirildiğinden printButton_Click ve PrintPage olayının PrintDocument örnekteki yöntemle ilişkilendirildiğinden pd_PrintPage emin olun. printButton_Click Örnekteki yöntemi olayı yükselten PrintPage yöntemini çağırır Print ve yönteminde pd_PrintPage belirtilen .bmp dosyasını yazdırır. Bu örneği çalıştırmak için, yolu yazdırmak istediğiniz bit eşlem olarak değiştirin.

System.DrawingBu örnek için , System.Drawing.Printingve System.Windows.Forms ad alanlarını kullanın.

private:
   // Specifies what happens when the user clicks the Button.
   void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         pd->Print();
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( "An error occurred while printing", ex->ToString() );
      }
   }

   // Specifies what happens when the PrintPage event is raised.
   void pd_PrintPage( Object^ /*sender*/, PrintPageEventArgs^ ev )
   {
      // Draw a picture.
      ev->Graphics->DrawImage( Image::FromFile( "C:\\My Folder\\MyFile.bmp" ),
         ev->Graphics->VisibleClipBounds );
      
      // Indicate that this is the last page to print.
      ev->HasMorePages = false;
   }

// Specifies what happens when the user clicks the Button.
 private void printButton_Click(object sender, EventArgs e) 
 {
   try 
   {
     // Assumes the default printer.
     pd.Print();
   }  
   catch(Exception ex) 
   {
     MessageBox.Show("An error occurred while printing", ex.ToString());
   }
 }
 
 // Specifies what happens when the PrintPage event is raised.
 private void pd_PrintPage(object sender, PrintPageEventArgs ev) 
 {      
   // Draw a picture.
   ev.Graphics.DrawImage(Image.FromFile("C:\\My Folder\\MyFile.bmp"), ev.Graphics.VisibleClipBounds);
      
   // Indicate that this is the last page to print.
   ev.HasMorePages = false;
 }
' Specifies what happens when the user clicks the Button.
Private Sub printButton_Click(sender As Object, e As EventArgs) _
Handles printButton.Click
    Try
       pd.Print()
    Catch ex As Exception
        MessageBox.Show("An error occurred while printing", _
            ex.ToString())
    End Try
End Sub    

' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs) _
Handles pd.PrintPage

    ' Draw a picture.
    ev.Graphics.DrawImage(Image.FromFile("C:\My Folder\MyFile.bmp"), _
        ev.Graphics.VisibleClipBounds)
    
    ' Indicate that this is the last page to print.
    ev.HasMorePages = False
End Sub

uygulamasının nasıl kullanılacağını HasMorePagesgösteren başka bir örnek için bkz. Nasıl yapılır: Windows Forms'da Çok Sayfalı Metin Dosyası Yazdırma.

Şunlara uygulanır

Ayrıca bkz.