Button.Index Özellik
Dizin numarasını alır Button koleksiyonu içinde OLEObjects sayfa üzerinde.
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
public int Index { get; }
Özellik Değeri
Tür: System.Int32
Dizin sayısı Button koleksiyonu içinde OLEObjects sayfa üzerinde.
Notlar
Microsoft Office Excel çalışma sayfalarına eklenen denetimler dizin değeriyle başlar 2'dizini olduğu için OLEObjects sayfa topluluğu.
Örnekler
Aşağıdaki kod örneğinde, üç ekler Button denetimlerini çalışma.Bu düğmeler paylaşmak bir Click olay işleyicisi kullanan Index özelliğini düğmenin tıklanmış dizini görüntülemek için.
Belge düzeyi özelleştirmesi için örnektir.
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
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen Güvenilen Koddan Kitaplıkları Kullanma.