Aracılığıyla paylaş


Button.Index Özellik

Dizin numarasını alır Button koleksiyonu içinde OLEObjects sayfası.

Ad alanı:  Microsoft.Office.Tools.Excel.Controls
Derleme:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll içinde)

Sözdizimi

'Bildirim
Public ReadOnly Property Index As Integer
    Get
public int Index { get; }

Özellik Değeri

Tür: System.Int32
Dizin numarası Button koleksiyonu içinde OLEObjects sayfası.

Açıklamalar

Microsoft Office Excel çalışma sayfasına eklenen denetimler dizin değeriyle başlatır at 2 dizini olduğu için OLEObjects topluluğu sayfa.

Örnekler

Aşağıdaki kod örneği üç ekler Button denetimleri çalışma. Bu düğmeler paylaşmak bir Click kullandığı olay işleyicisi Index tıklandığını düğmesini dizini görüntülemek için özellik.

Bu örnek, bir belge düzeyinde özelleştirme için bulunur.

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());
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

Button Sınıf

Microsoft.Office.Tools.Excel.Controls Ad Alanı