Sdílet prostřednictvím


Button.PrintObject – vlastnost

Získá nebo nastaví hodnotu, která označuje, zda Button tisku při tisku listu.

Obor názvů:  Microsoft.Office.Tools.Excel.Controls
Sestavení:  Microsoft.Office.Tools.Excel.v4.0.Utilities (v Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntaxe

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

Hodnota vlastnosti

Typ: System.Boolean
true Pokud Button tisku při tisku listu; jinak false.

Příklady

Následující příklad kódu ukazuje Button řízení s Clickobslužnou rutinuudálost , který generuje náhledu tisku list. Vyzve uživatel k určení, zda by tlačítko se v náhledu tisku nastavení obslužné rutiny událost PrintObjectvlastnost.

Tento příklad je přizpůsobení úrovni 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);
}

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

Button Třída

Microsoft.Office.Tools.Excel.Controls – obor názvů