PageSetupDialog.PrinterSettings Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Получает или задает параметры принтера, которые пользователь может изменить, нажав кнопку "Принтер" в диалоговом окне.
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
. Убедитесь, что событие нажатия кнопки подключено к методу обработки событий в этом примере.
//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