Print Dialog Класс
Определение
Вызывает стандартное диалоговое окно печати Microsoft Windows, которое настраивает объекты PrintTicket и PrintQueue в соответствии с введенными данными, а затем распечатывает документ. Invokes a standard Microsoft Windows print dialog box that configures a PrintTicket and PrintQueue according to user input and then prints a document.
Примеры
В следующем примере показано, как создать экземпляр и отобразить простой PrintDialog с помощью разметки XAML (XAML) и кода. The following example shows how to create an instance of and display a simple PrintDialog by using Extensible Application Markup Language (XAML) markup and code.
Комментарии
Пользователь может использовать диалоговое окно Печать , чтобы выбрать принтер, настроить его и выполнить задание печати. A user can use the Print dialog box to select a printer, configure it, and perform a print job.
Строго говоря, метод можно использовать PrintDocument без открытия диалогового окна. Strictly speaking, you can use the PrintDocument method without ever opening the dialog. В этом смысле элемент управления можно использовать как незамеченный компонент печати. In that sense, the control can be used as an unseen printing component. Но по соображениям производительности лучше использовать либо AddJob метод, либо один из множества Write WriteAsync методов и XpsDocumentWriter . But for performance reasons, it would be better to use either the AddJob method or one of the many Write and WriteAsync methods of the XpsDocumentWriter. Дополнительные сведения см. в разделе руководство. Программная печать файлов XPS. For more about this, see How to: Programmatically Print XPS Files.
Не путайте этот класс System.Windows.Controls.PrintDialog с System.Windows.Forms.PrintDialog . Do not confuse this class, System.Windows.Controls.PrintDialog, with System.Windows.Forms.PrintDialog. Последний используется с Windows Forms приложениями. The latter is used with Windows Forms applications. System.Windows.Controls.PrintDialog используется с приложениями Windows Presentation Foundation. System.Windows.Controls.PrintDialog is used with Windows Presentation Foundation applications.
Конструкторы
Инициализирует новый экземпляр класса PrintDialog. Initializes a new instance of the PrintDialog class.
Свойства
Получает или задает значение, указывающее, включена ли функция печати текущей страницы. Gets or sets a value that indicates whether the option to print the current page is enabled.
Возвращает или задает наибольший номер страницы, допустимый в диапазоне страниц. Gets or sets the highest page number that is allowed in page ranges.
Возвращает или задает наименьший номер страницы, допустимый в диапазоне страниц. Gets or sets the lowest page number that is allowed in page ranges.
Возвращает или задает печатаемый диапазон страниц, когда свойство PageRangeSelection получает значение UserPages. Gets or sets the range of pages to print when PageRangeSelection is set to UserPages.
Возвращает или задает свойство PageRangeSelection данного экземпляра класса PrintDialog. Gets or sets the PageRangeSelection for this instance of PrintDialog.
Возвращает высоту печатаемой области страницы. Gets the height of the printable area of the page.
Возвращает ширину печатаемой области страницы. Gets the width of the printable area of the page.
Возвращает или задает очередь PrintQueue, представляющую выбранный принтер. Gets or sets a PrintQueue that represents the printer that is selected.
Возвращает или задает объект PrintTicket, который используется объектом PrintDialog, когда пользователь нажимает кнопку Печать, чтобы выполнить текущее задание печати. Gets or sets the PrintTicket that is used by the PrintDialog when the user clicks Print for the current print job.
Получает или задает значение, указывающее, включена ли функция печати выбранных страниц. Gets or sets a value that indicates whether the option to print the selected pages is enabled.
Возвращает или задает значение, показывающее, могут ли пользователи диалогового окна Печать определять диапазон печатаемых страниц. Gets or sets a value that indicates whether users of the Print dialog box have the option to specify ranges of pages to print.
Методы
Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.
(Унаследовано от Object)
Служит хэш-функцией по умолчанию. Serves as the default hash function.
(Унаследовано от Object)
Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.
(Унаследовано от Object)
Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.
(Унаследовано от Object)
Печатает объект DocumentPaginator в очереди PrintQueue, выбранной на данный момент. Prints a DocumentPaginator object to the PrintQueue that is currently selected.
Печатает визуальный (нетекстовый) объект, производный из класса Visual, в очереди PrintQueue, выбранной на данный момент. Prints a visual (non-text) object, which is derived from the Visual class, to the PrintQueue that is currently selected.
Вызывает PrintDialog в качестве модального диалогового окна. Invokes the PrintDialog as a modal dialog box.
Возвращает строку, представляющую текущий объект. Returns a string that represents the current object.
Print Dialog Класс
Определение
Позволяет пользователям выбирать принтер и определять, какие разделы документа должны быть напечатаны из приложения Windows Forms. Lets users select a printer and choose which sections of the document to print from a Windows Forms application.
Примеры
В следующем примере кода показано, как использовать PrintDialog элемент управления для задания AllowSomePages свойств, ShowHelp и Document . The following code example demonstrates how to use the PrintDialog control to set the AllowSomePages, ShowHelp, and Document properties. Чтобы выполнить этот пример, вставьте следующий код в форму, содержащую PrintDialog элемент управления с именем PrintDialog1 и кнопку с именем Button1 . To run this example, paste the following code into a form that contains a PrintDialog control named PrintDialog1 and a button named Button1 . В этом примере требуется, Click чтобы событие кнопки и PrintPage событие были docToPrint подключены к методам обработки событий, определенным в этом примере. This example requires that the button’s Click event and the PrintPage event of docToPrint have been connected to the event-handling methods defined in this example.
Комментарии
При создании экземпляра PrintDialog свойства чтения и записи устанавливаются в начальные значения. When you create an instance of PrintDialog, the read/write properties are set to initial values. Список этих значений см. в конструкторе PrintDialog. For a list of these values, see the PrintDialog constructor. Чтобы получить параметры принтера, измененные пользователем с помощью PrintDialog , используйте PrinterSettings свойство. To get printer settings that are modified by the user with the PrintDialog, use the PrinterSettings property.
Дополнительные сведения о печати с помощью Windows Forms см. в разделе System.Drawing.Printing Общие сведения о пространстве имен. For more information about printing with Windows Forms, see the System.Drawing.Printing namespace overview. Если требуется выполнить печать из Windows Presentation Foundation приложения, см System.Printing . раздел пространство имен. If you want to print from a Windows Presentation Foundation application, see the System.Printing namespace.
Конструкторы
Инициализирует новый экземпляр класса PrintDialog. Initializes a new instance of the PrintDialog class.
Свойства
Получает или задает значение, указывающее, отображается ли переключатель Текущая страница. Gets or sets a value indicating whether the Current Page option button is displayed.
Получает или задает значение, указывающее, установлен ли флажок Печать в файл. Gets or sets a value indicating whether the Print to file check box is enabled.
Получает или задает значение, определяющее, включен ли переключатель Выбор. Gets or sets a value indicating whether the Selection option button is enabled.
Получает или задает значение, определяющее, включен ли переключатель Страницы. Gets or sets a value indicating whether the Pages option button is enabled.
Возвращает значение, показывающее, может ли компонент вызывать событие. Gets a value indicating whether the component can raise an event.
(Унаследовано от Component)
Возвращает объект IContainer, который содержит коллекцию Component. Gets the IContainer that contains the Component.
(Унаследовано от Component)
Возвращает значение, указывающее, находится ли данный компонент Component в режиме конструктора в настоящее время. Gets a value that indicates whether the Component is currently in design mode.
(Унаследовано от Component)
Получает или задает значение, указывающее, какой объект PrintDocument используется для получения PrinterSettings. Gets or sets a value indicating the PrintDocument used to obtain PrinterSettings.
Возвращает список обработчиков событий, которые прикреплены к этому объекту Component. Gets the list of event handlers that are attached to this Component.
(Унаследовано от Component)
Получает или задает параметры принтера, которые можно изменить в диалоговом окне. Gets or sets the printer settings the dialog box modifies.
Получает или задает значение, указывающее, установлен ли флажок Печать в файл. Gets or sets a value indicating whether the Print to file check box is selected.
Получает или задает значение, определяющее, отображается ли кнопка Справка. Gets or sets a value indicating whether the Help button is displayed.
Получает или задает значение, определяющее, отображается ли кнопка Сеть. Gets or sets a value indicating whether the Network button is displayed.
Получает или задает ISite объекта Component. Gets or sets the ISite of the Component.
(Унаследовано от Component)
Получает или задает объект, содержащий данные элемента управления. Gets or sets an object that contains data about the control.
(Унаследовано от CommonDialog)
Возвращает или задает значение, указывающее, должно ли диалоговое окно отображаться в стиле Windows XP для систем под управлением Windows XP Home Edition, Windows XP Professional, Windows Server 2003 или более поздней версии. Gets or sets a value indicating whether the dialog should be shown in the Windows XP style for systems running Windows XP Home Edition, Windows XP Professional, Windows Server 2003 or later.
Методы
Создает объект, который содержит всю необходимую информацию для создания прокси-сервера, используемого для взаимодействия с удаленным объектом. Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Унаследовано от MarshalByRefObject)
Освобождает все ресурсы, занятые модулем Component. Releases all resources used by the Component.
(Унаследовано от Component)
Освобождает неуправляемые ресурсы, используемые объектом Component, а при необходимости освобождает также управляемые ресурсы. Releases the unmanaged resources used by the Component and optionally releases the managed resources.
(Унаследовано от Component)
Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.
(Унаследовано от Object)
Служит хэш-функцией по умолчанию. Serves as the default hash function.
(Унаследовано от Object)
Извлекает объект обслуживания во время существования, который управляет политикой времени существования данного экземпляра. Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Унаследовано от MarshalByRefObject)
Возвращает объект, представляющий службу, предоставляемую классом Component или классом Container. Returns an object that represents a service provided by the Component or by its Container.
(Унаследовано от Component)
Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.
(Унаследовано от Object)
Определяет процедуру обработки общего диалогового окна, переопределенную, чтобы добавить специальные функции для общего диалогового окна. Defines the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box.
(Унаследовано от CommonDialog)
Получает объект службы времени существования для управления политикой времени существования для этого экземпляра. Obtains a lifetime service object to control the lifetime policy for this instance.
(Унаследовано от MarshalByRefObject)
Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.
(Унаследовано от Object)
Создает неполную копию текущего объекта MarshalByRefObject. Creates a shallow copy of the current MarshalByRefObject object.
(Унаследовано от MarshalByRefObject)
Вызывает событие HelpRequest. Raises the HelpRequest event.
(Унаследовано от CommonDialog)
Определяет процедуру окна-владельца, которая переопределяется, чтобы добавить специальные функции для общего диалогового окна. Defines the owner window procedure that is overridden to add specific functionality to a common dialog box.
(Унаследовано от CommonDialog)
Сбрасывает все параметры, принтер, который был выбран последним, и параметры страницы, присваивая значения, использующиеся по умолчанию. Resets all options, the last selected printer, and the page settings to their default values.
В случае переопределения в производном классе указывает общее диалоговое окно. When overridden in a derived class, specifies a common dialog box.
(Унаследовано от CommonDialog)
Запускает общее диалоговое окно с заданным по умолчанию владельцем. Runs a common dialog box with a default owner.
(Унаследовано от CommonDialog)
Запускает общее диалоговое окно с указанным владельцем. Runs a common dialog box with the specified owner.
(Унаследовано от CommonDialog)
Возвращает объект String, содержащий имя Component, если оно есть. Returns a String containing the name of the Component, if any. Этот метод не следует переопределять. This method should not be overridden.
(Унаследовано от Component)
События
Возникает при удалении компонента путем вызова метода Dispose(). Occurs when the component is disposed by a call to the Dispose() method.
(Унаследовано от Component)
Происходит при нажатии пользователем кнопки справки в общем диалоговом окне. Occurs when the user clicks the Help button on a common dialog box.