PageSetupDialog.PrinterSettings 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定當使用者按一下對話方塊中的 [印表機] 按鈕時,要修改的印表機設定。
public:
property System::Drawing::Printing::PrinterSettings ^ PrinterSettings { System::Drawing::Printing::PrinterSettings ^ get(); void set(System::Drawing::Printing::PrinterSettings ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Printing.PrinterSettings PrinterSettings { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Drawing.Printing.PrinterSettings? PrinterSettings { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.PrinterSettings : System.Drawing.Printing.PrinterSettings with get, set
Public Property PrinterSettings As PrinterSettings
屬性值
當使用者按一下 [印表機] 按鈕時要修改的 PrinterSettings。 預設為 null
。
- 屬性
範例
下列程式碼範例示範 PageSetupDialog 如何使用 PageSettings 、 PrinterSettings 和 ShowNetwork 屬性。 若要執行此範例,請將它放在表單中,其中包含 Button 名為 Button1
的 、 ListBox 名為 ListBox1
的 ,以及 PageSetupDialog 名為 PageSetupDialog1
的 。 請確定按鈕的 Click 事件已連線到此範例中的事件處理方法。
//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.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.
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