PageSetupDialog.PageSettings-Eigenschaft
Ruft einen Wert ab, der die zu ändernden Seiteneinstellungen angibt, oder legt diesen fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property PageSettings As PageSettings
'Usage
Dim instance As PageSetupDialog
Dim value As PageSettings
value = instance.PageSettings
instance.PageSettings = value
public PageSettings PageSettings { get; set; }
public:
property PageSettings^ PageSettings {
PageSettings^ get ();
void set (PageSettings^ value);
}
/** @property */
public PageSettings get_PageSettings ()
/** @property */
public void set_PageSettings (PageSettings value)
public function get PageSettings () : PageSettings
public function set PageSettings (value : PageSettings)
Eigenschaftenwert
Das zu ändernde PageSettings. Der Standardwert ist NULL (Nothing in Visual Basic).
Beispiel
Im folgenden Codebeispiel wird die Verwendung der PageSettings-Eigenschaft, der PrinterSettings-Eigenschaft und der ShowNetwork-Eigenschaft durch PageSetupDialog veranschaulicht. Fügen Sie das Beispiel zum Ausführen in ein Formular ein, das einen Button mit dem Namen Button1
, ein ListBox mit dem Namen ListBox1
und einen PageSetupDialog mit dem Namen PageSetupDialog1
enthält. Stellen Sie sicher, dass das Klickereignis der Schaltfläche der Methode zu Ereignisbehandlung in diesem Beispiel zugeordnet ist.
'This method displays a PageSetupDialog object. If the
' user clicks OK in the dialog, selected results of
' the dialog are displayed in ListBox1.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Initialize the dialog's PrinterSettings property to hold user
' defined printer settings.
PageSetupDialog1.PageSettings = _
New System.Drawing.Printing.PageSettings
' Initialize dialog's PrinterSettings property to hold user
' set printer settings.
PageSetupDialog1.PrinterSettings = _
New System.Drawing.Printing.PrinterSettings
'Do not show the network in the printer dialog.
PageSetupDialog1.ShowNetwork = False
'Show the dialog storing the result.
Dim result As DialogResult = PageSetupDialog1.ShowDialog()
' If the result is OK, display selected settings in
' ListBox1. These values can be used when printing the
' document.
If (result = DialogResult.OK) Then
Dim results() As Object = New Object() _
{PageSetupDialog1.PageSettings.Margins, _
PageSetupDialog1.PageSettings.PaperSize, _
PageSetupDialog1.PageSettings.Landscape, _
PageSetupDialog1.PrinterSettings.PrinterName, _
PageSetupDialog1.PrinterSettings.PrintRange}
ListBox1.Items.AddRange(results)
End If
End Sub
//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Initialize the dialog's PrinterSettings property to hold user
// defined printer settings.
PageSetupDialog1.PageSettings =
new System.Drawing.Printing.PageSettings();
// Initialize dialog's PrinterSettings property to hold user
// set printer settings.
PageSetupDialog1.PrinterSettings =
new System.Drawing.Printing.PrinterSettings();
//Do not show the network in the printer dialog.
PageSetupDialog1.ShowNetwork = false;
//Show the dialog storing the result.
DialogResult result = PageSetupDialog1.ShowDialog();
// If the result is OK, display selected settings in
// ListBox1. These values can be used when printing the
// document.
if ( result == DialogResult.OK)
{
object[] results = new object[]{
PageSetupDialog1.PageSettings.Margins,
PageSetupDialog1.PageSettings.PaperSize,
PageSetupDialog1.PageSettings.Landscape,
PageSetupDialog1.PrinterSettings.PrinterName,
PageSetupDialog1.PrinterSettings.PrintRange};
ListBox1.Items.AddRange(results);
}
}
//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Initialize the dialog's PrinterSettings property to hold user
// defined printer settings.
PageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings;
// Initialize dialog's PrinterSettings property to hold user
// set printer settings.
PageSetupDialog1->PrinterSettings = gcnew System::Drawing::Printing::PrinterSettings;
//Do not show the network in the printer dialog.
PageSetupDialog1->ShowNetwork = false;
//Show the dialog storing the result.
System::Windows::Forms::DialogResult result = PageSetupDialog1->ShowDialog();
// If the result is OK, display selected settings in
// ListBox1. These values can be used when printing the
// document.
if ( result == ::DialogResult::OK )
{
array<Object^>^results = {PageSetupDialog1->PageSettings->Margins,PageSetupDialog1->PageSettings->PaperSize,PageSetupDialog1->PageSettings->Landscape,PageSetupDialog1->PrinterSettings->PrinterName,PageSetupDialog1->PrinterSettings->PrintRange};
ListBox1->Items->AddRange( results );
}
}
//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
private void button1_Click(System.Object sender, System.EventArgs e)
{
// Initialize the dialog's PrinterSettings property to hold user
// defined printer settings.
pageSetupDialog1.set_PageSettings(
new System.Drawing.Printing.PageSettings());
// Initialize dialog's PrinterSettings property to hold user
// set printer settings.
pageSetupDialog1.set_PrinterSettings(
new System.Drawing.Printing.PrinterSettings());
//Do not show the network in the printer dialog.
pageSetupDialog1.set_ShowNetwork(false);
//Show the dialog storing the result.
DialogResult result = pageSetupDialog1.ShowDialog();
// If the result is OK, display selected settings in
// ListBox1. These values can be used when printing the
// document.
if (result.Equals(get_DialogResult().OK)) {
Object results[] = new Object[] {
pageSetupDialog1.get_PageSettings().get_Margins(),
pageSetupDialog1.get_PageSettings().get_PaperSize(),
((System.Boolean)pageSetupDialog1.get_PageSettings().
get_Landscape()),
pageSetupDialog1.get_PrinterSettings().get_PrinterName(),
pageSetupDialog1.get_PrinterSettings().get_PrintRange()};
listBox1.get_Items().AddRange(results);
}
} //button1_Click
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, 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
PageSetupDialog-Klasse
PageSetupDialog-Member
System.Windows.Forms-Namespace
PageSettings