ControlCollection.IndexOf أسلوب (Object)
يبحث عن الفرعي عنصر تحكم وإرجاع الفهرس zero-based أول في ControlCollectionالمثيل.
مساحة الاسم: Microsoft.Office.Tools.Excel
التجميع: Microsoft.Office.Tools.Excel (في Microsoft.Office.Tools.Excel.dll)
بناء الجملة
'إقرار
Function IndexOf ( _
control As Object _
) As Integer
int IndexOf(
Object control
)
المعلمات
- control
النوع: System.Object
عنصر تحكم للعثور على الفهرس.
القيمة المُرجعة
النوع: System.Int32
الفهرس عنصر تحكم، أو إذا كان-1 عنصر تحكم غير موجود في ControlCollectionالمثيل.
أمثلة
مثال التعليمة البرمجية التالية يضيف Buttonعنصر تحكم إلى أعلى ورقة عمل، ثم يعرض فهرس الزر في صندوق رسالة.
Private Sub ExcelControlIndexOf()
Dim Button1 As Microsoft.Office.Tools.Excel. _
Controls.Button = Me.Controls.AddButton( _
0, 0, 56.25, 17.25, "Button1")
Button1.Text = "OK"
If Me.Controls.Contains(Button1) Then
MessageBox.Show("The index of Button1 is " _
& Controls.IndexOf(Button1))
End If
End Sub
private void ExcelControlIndexOf()
{
Microsoft.Office.Tools.Excel.Controls.Button button1 =
this.Controls.AddButton(0, 0, 56.25, 17.25,
"button1");
button1.Text = "OK";
if (this.Controls.Contains(button1))
{
MessageBox.Show("The index of button1 is " +
Controls.IndexOf(button1));
}
}
أمن NET Framework.
- الثقة الكاملة للمتصل الفوري. يتعذر استخدام هذا العضو بواسطة التعليمات البرمجية الموثوق بها جزئيًا. لمزيد من المعلومات، راجع باستخدام مكتبات من تعليمات برمجية موثوق بها جزئي.