1 / 9

PRINTDIALOGS

PRINTDIALOGS. Permite a los usuarios seleccionar una impresora y elegir qué secciones del documento se van a imprimir, al imprimir desde una aplicación de formularios Windows Forms.

brian
Download Presentation

PRINTDIALOGS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PRINTDIALOGS Permite a los usuarios seleccionar una impresora y elegir qué secciones del documento se van a imprimir, al imprimir desde una aplicación de formularios Windows Forms

  2. El componente PrintDialog de formularios Windows Forms es un cuadro de diálogo preconfigurado que se utiliza para seleccionar una impresora, elegir las páginas que se van a imprimir y determinar otros valores de configuración relacionados con la impresión en aplicaciones basadas en Windows. Utilícelo como una solución sencilla para seleccionar configuraciones de la impresora o relacionadas con la impresora, en lugar de configurar un cuadro de diálogo propio. Puede permitir que los usuarios impriman diversas partes de sus documentos: imprimir todo, imprimir el intervalo de páginas especificado o imprimir una selección. Al basarse en cuadros de diálogo estándar de Windows, creará aplicaciones cuya funcionalidad básica les resultará inmediatamente familiar a los usuarios

  3. Imprimir diálogos cuentan con el apoyo de la clase PrintDialog y que nos permiten imprimir el documento. Para imprimir un documento que necesitamos para establecer los documentos de propiedad de la PrintDialog a objeto PrintDocument y PrinterSettings a PrinterSettings objeto. Puede imprimir el documento de asignación de PrintDialog del objeto PrinterSettings propiedad PrinterSettings a la propiedad del objeto PrintDocument y el uso del objeto PrintDocument método de impresión.

  4. Propiedades de la ventana de impresión son las siguientes: AllowPrintTofile: Obtiene / Establece si el archivo a imprimir casilla de verificación está activada. AllowSelection: Obtiene / Establece si la selección de radio está activada. AllowSomePages: Obtiene / Establece si el De ... Para ... Page botón de opción está activada. Documento: Obtiene / Establece el PrintDocument utilizarse para obtener PrinterSettings PrinterSettings: Obtiene / Establece el PrinterSettings cuadro de diálogo para modificar. PrintToFile: Obtiene / Establece si el archivo a imprimir casilla de verificación está activada. ShowHelp: Obtiene / Establece si el botón de Ayuda en la pantalla. ShowNetwork: Obtiene / Establece si la red botón en la pantalla.

  5. Sintaxis Cuando se crea una instancia de PrintDialog, se establecen las propiedades de lectura y escritura en sus valores iniciales. Public NotInheritable class PrintDialog InheristCommonDialog

  6. En el ejemplo de código siguiente se muestra cómo utilizar el control PrintDialog para establecer las propiedades AllowSomePages, ShowHelp y Document. Para ejecutar este ejemplo, pegue el siguiente código en un formulario que contiene un control PrintDialog denominado PrintDialog1 y un botón denominado Button1. En este ejemplo se requiere que el evento Click del botón y el evento PrintPage de docToPrint se hayan conectado a los métodos de control de eventos definidos en este ejemplo.

  7. ' Declare the PrintDocument object .PrivateWithEvents docToPrint AsNew Printing.PrintDocument ' This method will set properties on the PrintDialog object and' then display the dialog .PrivateSub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click ' Allow the user to choose the page range he or she would ' like to print. PrintDialog1.AllowSomePages = True ' Show the help button. PrintDialog1.ShowHelp = True ' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set PrintDialog1.Document = docToPrint Dim result As DialogResult = PrintDialog1.ShowDialog() ' If the result is OK then print the document. If (result = DialogResult.OK) Then docToPrint.Print() EndIf EndSub ' The PrintDialog will print the document • ' by handling the document's PrintPage event

  8. .PrivateSub document_PrintPage(ByVal sender AsObject, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles docToPrint.PrintPage • ' Insert code to render the page here. • ' This code will be called when the control is drawn. • ' The following code will render a simple • ' message on the printed document. • Dim text AsString = "In document_PrintPage method." • Dim printFont AsNew System.Drawing.Font _ • ("Arial", 35, System.Drawing.FontStyle.Regular) • ' Draw the content. • e.Graphics.DrawString(text, printFont, _ System.Drawing.Brushes.Black, 10, 10) • EndSub

  9. NOMBRES: Dainiri camargo Tatiana sotoCURSO: 40073

More Related