Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

Classe PageSetupDialog

Permite aos usuários alterar relacionados à página Configurações de impressão, incluindo as margens e orientação do papel. Esta classe não pode ser herdada.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms.dll)
public sealed class PageSetupDialog : CommonDialog

The PageSetupDialog caixa de diálogo modifica o PageSettings e PrinterSettings informações para um determinado Document. O usuário poderá ativar seções da caixa de diálogo para manipular a impressão e margens; fonte; dimensionar e orientação do papel e para mostrar a Ajuda e rede botões. The MinMargins propriedade define as margens mínimas, que um usuário pode selecionar.

Quando você cria uma instância do PageSetupDialog classe, as propriedades de leitura/gravar são definidas como valores iniciais. Para obter uma lista desses valores, consulte o PageSetupDialog construtor.

Porque um PageSetupDialog precisa de página de configurações para exibir, você precisa conjunto a Document, PrinterSettings, ou PageSettings propriedade antes de ligar ShowDialog; Caso contrário, ocorrerá uma exceção.

O exemplo de código a seguir demonstra o PageSetupDialog usando o PageSettings, PrinterSettings, e ShowNetwork Propriedades. Para executar esse exemplo, coloque-o em um formulário que contém um Button chamada Button1, um ListBox chamada ListBox1e um PageSetupDialog chamada PageSetupDialog1. Certifique-se de clicar do botão de evento está conectado ao método de manipulação de evento neste exemplo.

//This method displays a PageSetupDialog object. If the// user clicks OK in the dialog, selected results of// the dialog are displayed in ListBox1.privatevoid 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 void button1_Click(System.Object sender, System.EventArgs e)
    {
        // Initialize the dialog's PrinterSettings property to hold user
        // defined printer settings.
        pageSetupDialog1.set_PageSettings(
            new System.Drawing.Printing.PageSettings());
        // Initialize dialog's PrinterSettings property to hold user
        // set printer settings.
        pageSetupDialog1.set_PrinterSettings(
            new System.Drawing.Printing.PrinterSettings());
        //Do not show the network in the printer dialog.
        pageSetupDialog1.set_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.Equals(get_DialogResult().OK)) {
            Object results[] = new Object[] {
                pageSetupDialog1.get_PageSettings().get_Margins(),
                pageSetupDialog1.get_PageSettings().get_PaperSize(),
                ((System.Boolean)pageSetupDialog1.get_PageSettings().
                get_Landscape()),
                pageSetupDialog1.get_PrinterSettings().get_PrinterName(),
                pageSetupDialog1.get_PrinterSettings().get_PrintRange()};
            listBox1.get_Items().AddRange(results);
        }
	
    } //button1_Click


Quaisquer membros static (Shared no Visual Basic) públicos deste tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

o.NET Framework e.NET Compact Framework não oferecem suporte a todas as versões de cada plataforma. Para obter uma lista de versões suportadas, consulte Requisitos de sistema do .NET framework.

.NET Framework

Compatível com: 3.5, 3.0, 2.0, 1.1, 1.0
Isso foi útil para você?
(1500 caracteres restantes)
Conteúdo da Comunidade Adicionar