Sdílet prostřednictvím


Button.Index – vlastnost

Získá číslo indexu Button v rámci kolekce OLEObjects na list.

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
Public ReadOnly Property Index As Integer
    Get
public int Index { get; }

Hodnota vlastnosti

Typ: System.Int32
Indexové číslo Button v rámci kolekce OLEObjects na list.

Poznámky

Hodnota index ovládací prvky přidané do list aplikace Excel systém Microsoft Office začíná na 2, protože index je OLEObjectskolekce list.

Příklady

Následující příklad kódu přidá tři Button prvky list. Sdílet tato tlačítka Clickobslužnou rutinuudálost , která používá Indexvlastnost index jste klepli na tlačítko zobrazit.

Tento příklad je přizpůsobení úrovni dokumentu.

Private Sub DisplayIndex()
    Dim IndexButton1 As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "IndexButton1")
    IndexButton1.Text = "Click to view the index"
    AddHandler IndexButton1.Click, AddressOf indexButton_Click

    Dim IndexButton2 As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B5", "C6"), "IndexButton2")
    IndexButton2.Text = "Click to view the index"
    AddHandler IndexButton2.Click, AddressOf indexButton_Click

    Dim IndexButton3 As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B8", "C9"), "IndexButton3")
    IndexButton3.Text = "Click to view the index"
    AddHandler IndexButton3.Click, AddressOf indexButton_Click
End Sub

Private Sub IndexButton_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)

    MsgBox("The index is " & ClickedButton.Index.ToString())
End Sub
private void DisplayIndex()
{
    Microsoft.Office.Tools.Excel.Controls.Button indexButton1 =
            this.Controls.AddButton(this.Range["B2", "C3"],
            "indexButton1");
    indexButton1.Text = "Click to view the index";
    indexButton1.Click += new EventHandler(indexButton_Click);

    Microsoft.Office.Tools.Excel.Controls.Button indexButton2 =
            this.Controls.AddButton(this.Range["B5", "C6"],
            "indexButton2");
    indexButton2.Text = "Click to view the index";
    indexButton2.Click += new EventHandler(indexButton_Click);

    Microsoft.Office.Tools.Excel.Controls.Button indexButton3 =
            this.Controls.AddButton(this.Range["B8", "C9"],
            "indexButton3");
    indexButton3.Text = "Click to view the index";
    indexButton3.Click += new EventHandler(indexButton_Click);
}

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

    MessageBox.Show("The index is " +
        clickedButton.Index.ToString());
}

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

Button Třída

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