مشاركة عبر


ControlCollection.Contains أسلوب (Object)

تحديد ما إذا كان عنصر التحكم المحدد عضو في ControlCollectionالمثيل.

مساحة الاسم:  Microsoft.Office.Tools.Excel
التجميع:  Microsoft.Office.Tools.Excel (في Microsoft.Office.Tools.Excel.dll)

بناء الجملة

'إقرار
Function Contains ( _
    control As Object _
) As Boolean
bool Contains(
    Object control
)

المعلمات

القيمة المُرجعة

النوع: System.Boolean
trueإذا كان عنصر تحكم تم العثور عليه في المجموعة؛ وإلا،false.

أمثلة

مثال التعليمة البرمجية التالية يضيف 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.

راجع أيضًَا

المرجع

ControlCollection واجهة

ControlCollection الأعضاء

Contains التحميل الزائد

Microsoft.Office.Tools.Excel مساحة الاسم