- Компонент PrintDialog (Windows Forms) PrintDialog Component (Windows Forms)
- в этом разделе In This Section
- Справочник Reference
- Связанные разделы Related Sections
- Общие сведения о компоненте PrintDialog (Windows Forms) PrintDialog Component Overview (Windows Forms)
- Работа с компонентом Working with the Component
- Print Dialog Class
- Definition
- Examples
- Remarks
- Constructors
- Properties
- Methods
- Events
- Print Dialog Class
- Definition
- Examples
- Remarks
- Constructors
- Properties
- Methods
- Print Dialog Класс
- Определение
- Примеры
- Комментарии
- Конструкторы
- Свойства
- Методы
- События
Компонент PrintDialog (Windows Forms) PrintDialog Component (Windows Forms)
Компонент PrintDialog Windows Forms является предварительно настроенным диалоговым окном, используемым для выбора принтера и печатаемых страниц, а также для определения других параметров печати в приложениях Windows. The Windows Forms PrintDialog component is a pre-configured dialog box used to select a printer, choose the pages to print, and determine other print-related settings in Windows-based applications. Он используется в качестве простого решения для выбора принтера и параметров печати вместо самостоятельной настройки диалогового окна. Use it as a simple solution for printer and print-related settings selection in lieu of configuring your own dialog box. Пользователям можно предоставить различные варианты печати документов: печать всех страниц, указанного диапазона страниц или выделенного фрагмента текста. You can enable users to print many parts of their documents: print all, print a specified page range, or print a selection. Использование стандартных диалоговых окон Windows помогает создавать приложения, основные функциональные возможности которых хорошо знакомы пользователям. By relying on standard Windows dialog boxes, you create applications whose basic functionality is immediately familiar to users.
в этом разделе In This Section
Общие сведения о компоненте PrintDialog PrintDialog Component Overview
Основные понятия, связанные с компонентом PrintDialog , который служит для вывода стандартного диалогового окна для выбора принтера и печатаемых страниц, а также для задания параметров печати. Introduces the general concepts of the PrintDialog component, which allows you to display a pre-configured dialog box that users can use to select a printer, choose pages to print, and determine print-related settings.
Практическое руководство. Отображение компонента PrintDialog How to: Display the PrintDialog Component
Инструкции по выводу диалогового окна и заданию расположения для сохранения свойств. Explains how to display the dialog and where it saves properties.
Справочник Reference
PrintDialog
Справочная информация о классе и его членах. Provides reference information on the class and its members.
Связанные разделы Related Sections
Элементы управления для использования в формах Windows Forms Controls to Use on Windows Forms
Полный список элементов управления Windows Forms со ссылками на информацию об их применении. Provides a complete list of Windows Forms controls, with links to information on their use.
Общие сведения о компоненте PrintDialog (Windows Forms) PrintDialog Component Overview (Windows Forms)
Компонент Windows Forms PrintDialog — это предварительно настроенное диалоговое окно, используемое для выбора принтера, выбора страниц для печати и определения других параметров печати в приложениях Windows. The Windows Forms PrintDialog component is a pre-configured dialog box used to select a printer, choose the pages to print, and determine other print-related settings in Windows-based applications. Он используется в качестве простого решения для выбора принтера и параметров печати вместо самостоятельной настройки диалогового окна. Use it as a simple solution for printer and print-related settings selection in lieu of configuring your own dialog box. Вы можете разрешить пользователям печатать много частей документов: Печать всего, Печать выделенного диапазона страниц или Печать выделенного фрагмента. You can enable users to print many parts of their documents: print all, print a selected page range, or print a selection. Использование стандартных диалоговых окон Windows помогает создавать приложения, основные функциональные возможности которых хорошо знакомы пользователям. By relying on standard Windows dialog boxes, you create applications whose basic functionality is immediately familiar to users. PrintDialogКомпонент наследуется от CommonDialog класса. The PrintDialog component inherits from the CommonDialog class.
Работа с компонентом Working with the Component
Используйте ShowDialog метод для вывода диалогового окна во время выполнения. Use the ShowDialog method to display the dialog box at run time. Этот компонент имеет свойства, относящиеся к одному заданию печати ( PrintDocument классу) или параметрам отдельного принтера ( PrinterSettings класса). This component has properties that relate to either a single print job (PrintDocument class) or the settings of an individual printer (PrinterSettings class). Любой из них, в свою очередь, может совместно использоваться несколькими принтерами. Either of these, in turn, may be shared by multiple printers.
При добавлении в форму PrintDialog компонент отображается в области в нижней части конструктор Windows Forms в Visual Studio. When it is added to a form, the PrintDialog component appears in the tray at the bottom of the Windows Forms Designer in Visual Studio.
Print Dialog Class
Definition
Lets users select a printer and choose which sections of the document to print from a Windows Forms application.
Examples
The following code example demonstrates how to use the PrintDialog control to set the AllowSomePages, ShowHelp, and Document properties. To run this example, paste the following code into a form that contains a PrintDialog control named PrintDialog1 and a button named Button1 . 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.
Remarks
When you create an instance of PrintDialog, the read/write properties are set to initial values. For a list of these values, see the PrintDialog constructor. To get printer settings that are modified by the user with the PrintDialog, use the PrinterSettings property.
For more information about printing with Windows Forms, see the System.Drawing.Printing namespace overview. If you want to print from a Windows Presentation Foundation application, see the System.Printing namespace.
Constructors
Initializes a new instance of the PrintDialog class.
Properties
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.
(Inherited from Component)
Gets the IContainer that contains the Component.
(Inherited from Component)
Gets a value that indicates whether the Component is currently in design mode.
(Inherited from Component)
Gets or sets a value indicating the PrintDocument used to obtain PrinterSettings.
Gets the list of event handlers that are attached to this Component.
(Inherited from 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.
Gets or sets the ISite of the Component.
(Inherited from Component)
Gets or sets an object that contains data about the control.
(Inherited from CommonDialog)
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.
Methods
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject)
Releases all resources used by the Component.
(Inherited from Component)
Releases the unmanaged resources used by the Component and optionally releases the managed resources.
(Inherited from Component)
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Serves as the default hash function.
(Inherited from Object)
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Returns an object that represents a service provided by the Component or by its Container.
(Inherited from Component)
Gets the Type of the current instance.
(Inherited from Object)
Defines the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box.
(Inherited from CommonDialog)
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Creates a shallow copy of the current Object.
(Inherited from Object)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject)
Raises the HelpRequest event.
(Inherited from CommonDialog)
Defines the owner window procedure that is overridden to add specific functionality to a common dialog box.
(Inherited from 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.
(Inherited from CommonDialog)
Runs a common dialog box with a default owner.
(Inherited from CommonDialog)
Runs a common dialog box with the specified owner.
(Inherited from CommonDialog)
Returns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component)
Events
Occurs when the component is disposed by a call to the Dispose() method.
(Inherited from Component)
Occurs when the user clicks the Help button on a common dialog box.
Print Dialog Class
Definition
Invokes a standard Microsoft Windows print dialog box that configures a PrintTicket and PrintQueue according to user input and then prints a document.
Examples
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.
Remarks
A user can use the Print dialog box to select a printer, configure it, and perform a print job.
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. 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. For more about this, see How to: Programmatically Print XPS Files.
Do not confuse this class, System.Windows.Controls.PrintDialog, with System.Windows.Forms.PrintDialog. The latter is used with Windows Forms applications. System.Windows.Controls.PrintDialog is used with Windows Presentation Foundation applications.
Constructors
Initializes a new instance of the PrintDialog class.
Properties
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.
Gets or sets the range of pages to print when PageRangeSelection is set to UserPages.
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.
Gets or sets a PrintQueue that represents the printer that is selected.
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.
Methods
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Serves as the default hash function.
(Inherited from Object)
Gets the Type of the current instance.
(Inherited from Object)
Creates a shallow copy of the current Object.
(Inherited from Object)
Prints a DocumentPaginator object to the PrintQueue that is currently selected.
Prints a visual (non-text) object, which is derived from the Visual class, to the PrintQueue that is currently selected.
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.