Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft die Papiergröße für diese Seite ab oder legt diese fest.
Namespace: System.Drawing.Printing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Property PaperSize As PaperSize
'Usage
Dim instance As PageSettings
Dim value As PaperSize
value = instance.PaperSize
instance.PaperSize = value
public PaperSize PaperSize { get; set; }
public:
property PaperSize^ PaperSize {
PaperSize^ get ();
void set (PaperSize^ value);
}
/** @property */
public PaperSize get_PaperSize ()
/** @property */
public void set_PaperSize (PaperSize value)
public function get PaperSize () : PaperSize
public function set PaperSize (value : PaperSize)
Eigenschaftenwert
Eine PaperSize, die die Papiergröße darstellt. Der Standardwert entspricht dem Standardpapierformat des Druckers.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der in der PrinterSettings.PrinterName-Eigenschaft bezeichnete Drucker ist nicht vorhanden, oder es wurde kein Standarddrucker installiert. |
Hinweise
Eine PaperSize stellt die Papiergröße über die PaperSize.Kind-Eigenschaft dar, in der einer der PaperKind-Werte enthalten ist.
Legen Sie die PaperSize-Eigenschaft für die Seite auf eine gültige PaperSize fest, die in der PrinterSettings.PaperSizes-Auflistung verfügbar ist.
Informationen darüber, wie Sie ein benutzerdefiniertes Papierformat angeben können, finden Sie unter dem PaperSize-Konstruktor.
Beispiel
Im folgenden Codebeispiel werden drei Eigenschaften für die Standardseite des Dokuments festgelegt, einschließlich des Papierformats, das auf der Grundlage des im comboPaperSize-Kombinationsfeld ausgewählten Formats festgelegt wird. Daraufhin wird das Dokument mit der Print-Methode gedruckt. Im Beispiel müssen die PrintDocument-Variable printDoc sowie die bestimmten Kombinationsfelder vorhanden sein.
Private Sub MyButtonPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButtonPrint.Click
' Set the paper size based upon the selection in the combo box.
If comboPaperSize.SelectedIndex <> -1 Then
printDoc.DefaultPageSettings.PaperSize = _
printDoc.PrinterSettings.PaperSizes.Item(comboPaperSize.SelectedIndex)
End If
' Set the paper source based upon the selection in the combo box.
If comboPaperSource.SelectedIndex <> -1 Then
printDoc.DefaultPageSettings.PaperSource = _
printDoc.PrinterSettings.PaperSources.Item(comboPaperSource.SelectedIndex)
End If
' Set the printer resolution based upon the selection in the combo box.
If comboPrintResolution.SelectedIndex <> -1 Then
printDoc.DefaultPageSettings.PrinterResolution = _
printDoc.PrinterSettings.PrinterResolutions.Item(comboPrintResolution.SelectedIndex)
End If
' Print the document with the specified paper size and source.
printDoc.Print()
End Sub
private void MyButtonPrint_Click(object sender, System.EventArgs e)
{
// Set the paper size based upon the selection in the combo box.
if (comboPaperSize.SelectedIndex != -1) {
printDoc.DefaultPageSettings.PaperSize =
printDoc.PrinterSettings.PaperSizes[comboPaperSize.SelectedIndex];
}
// Set the paper source based upon the selection in the combo box.
if (comboPaperSource.SelectedIndex != -1) {
printDoc.DefaultPageSettings.PaperSource =
printDoc.PrinterSettings.PaperSources[comboPaperSource.SelectedIndex];
}
// Set the printer resolution based upon the selection in the combo box.
if (comboPrintResolution.SelectedIndex != -1)
{
printDoc.DefaultPageSettings.PrinterResolution=
printDoc.PrinterSettings.PrinterResolutions[comboPrintResolution.SelectedIndex];
}
// Print the document with the specified paper size, source, and print resolution.
printDoc.Print();
}
private:
void MyButtonPrint_Click( Object^ sender, System::EventArgs^ e )
{
// Set the paper size based upon the selection in the combo box.
if ( comboPaperSize->SelectedIndex != -1 )
{
printDoc->DefaultPageSettings->PaperSize = printDoc->PrinterSettings->PaperSizes[ comboPaperSize->SelectedIndex ];
}
// Set the paper source based upon the selection in the combo box.
if ( comboPaperSource->SelectedIndex != -1 )
{
printDoc->DefaultPageSettings->PaperSource = printDoc->PrinterSettings->PaperSources[ comboPaperSource->SelectedIndex ];
}
// Set the printer resolution based upon the selection in the combo box.
if ( comboPrintResolution->SelectedIndex != -1 )
{
printDoc->DefaultPageSettings->PrinterResolution = printDoc->PrinterSettings->PrinterResolutions[ comboPrintResolution->SelectedIndex ];
}
// Print the document with the specified paper size, source, and print resolution.
printDoc->Print();
}
private void myButtonPrint_Click(Object sender, System.EventArgs e)
{
// Set the paper size based upon the selection in the combo box.
if (comboPaperSize.get_SelectedIndex() != -1) {
printDoc.get_DefaultPageSettings().set_PaperSize(printDoc.
get_PrinterSettings().get_PaperSizes().
get_Item(comboPaperSize.get_SelectedIndex()));
}
// Set the paper source based upon the selection in the combo box.
if (comboPaperSource.get_SelectedIndex() != -1) {
printDoc.get_DefaultPageSettings().set_PaperSource(printDoc.
get_PrinterSettings().get_PaperSources().
get_Item(comboPaperSource.get_SelectedIndex()));
}
// Set the printer resolution based upon the selection in the combo box.
if (comboPrintResolution.get_SelectedIndex() != -1) {
printDoc.get_DefaultPageSettings().set_PrinterResolution(printDoc.
get_PrinterSettings().get_PrinterResolutions().
get_Item(comboPrintResolution.get_SelectedIndex()));
}
// Print the document with the specified paper size, source,
// and print resolution.
printDoc.Print();
} //myButtonPrint_Click
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
PageSettings-Klasse
PageSettings-Member
System.Drawing.Printing-Namespace
PaperSize
PaperSize.Height
PaperSize.Kind
PaperSize.Width