Właściwość Button.PrintObject —

Pobiera lub ustawia wartość wskazującą, czy Button jest drukowany podczas drukowania arkusza.

Przestrzeń nazw:  Microsoft.Office.Tools.Excel.Controls
Zestaw:  Microsoft.Office.Tools.Excel.v4.0.Utilities (w Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Składnia

'Deklaracja
<BrowsableAttribute(False)> _
Public Property PrintObject As Boolean
[BrowsableAttribute(false)]
public bool PrintObject { get; set; }

Wartość właściwości

Typ: System.Boolean
true Jeśli Button jest drukowany podczas drukowania arkusza; w przeciwnym razie false.

Przykłady

Poniższy przykład kodu pokazuje Button sterować za pomocą Click obsługi zdarzeń, który generuje podgląd wydruku arkusza.Program obsługi zdarzeń monituje użytkownika, aby określić, czy przycisk powinien pojawić się w podglądzie wydruku przez ustawienie PrintObject właściwość.

W tym przykładzie jest dla dostosowania poziomu dokumentu.

Private Sub PrintControl()

    Dim PrintButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("C2", "D3"), "PrintButton")
    PrintButton.Text = "Print preview"
    AddHandler PrintButton.Click, AddressOf printButton_Click

    ' Set a range value so that a print preview is generated even
    ' if the button is hidden from the preview.
    Me.Range("A1", "A10").Value2 = 123
End Sub

Private Sub PrintButton_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    ' Allow the user to hide the button from print previews.
    If DialogResult.No = MessageBox.Show( _
        "Include the button when printing the sheet?", "Example", _
        MessageBoxButtons.YesNo) Then
        ClickedButton.PrintObject = False
    End If
    Me.PrintPreview(True)
End Sub
private void PrintControl()
{
    Microsoft.Office.Tools.Excel.Controls.Button printButton =
            this.Controls.AddButton(this.Range["C2", "D3"],
            "printButton");
    printButton.Text = "Print preview";
    printButton.Click += new EventHandler(printButton_Click);

    // Set a range value so that a print preview is generated even
    // if the button is hidden from the preview.
    this.Range["A1", "A10"].Value2 = 123;
}

void printButton_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    if (DialogResult.No ==
        MessageBox.Show("Include the button when printing the sheet?",
        "Example", MessageBoxButtons.YesNo))
    {
        clickedButton.PrintObject = false;
    }
    this.PrintPreview(true);
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

Button Klasa

Przestrzeń nazw Microsoft.Office.Tools.Excel.Controls