Freigeben über


ControlCollection.Contains-Methode

Bestimmt, ob sich das angegebene Serversteuerelement im ControlCollection-Objekt des übergeordneten Serversteuerelements befindet.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Public Overridable Function Contains ( _
    c As Control _
) As Boolean
'Usage
Dim instance As ControlCollection
Dim c As Control
Dim returnValue As Boolean

returnValue = instance.Contains(c)
public virtual bool Contains (
    Control c
)
public:
virtual bool Contains (
    Control^ c
)
public boolean Contains (
    Control c
)
public function Contains (
    c : Control
) : boolean

Parameter

  • c
    Das Serversteuerelement, nach dem in der Auflistung gesucht werden soll.

Rückgabewert

true, wenn das angegebene Serversteuerelement in der Auflistung enthalten ist, andernfalls false.

Beispiel

     ' Create an event handler that uses the 
     ' ControlCollection.Contains method to verify
     ' the existence of a Radio3 server control in
     ' the ControlCollection of the myForm server control.
     ' When a user clicks the button associated
     ' with this event handler, Radio3 is removed
     ' from the collection.
Sub RemoveBtn_Click(sender As [Object], e As EventArgs)
      If myForm.Controls.Contains(Radio3) Then
           myForm.Controls.Remove(Radio3)
      End If
End Sub 'RemoveBtn_Click
// Create an event handler that uses the 
// ControlCollection.Contains method to verify
// the existence of a Radio3 server control in
// the ControlCollection of the myForm server control.
// When a user clicks the button associated
// with this event handler, Radio3 is removed
// from the collection.
void RemoveBtn_Click(Object sender, EventArgs e){
    if (myForm.Controls.Contains(Radio3))
    { 
       myForm.Controls.Remove(Radio3);
    }
}
// Create an event handler that uses the 
// ControlCollection.Contains method to verify
// the existence of a Radio3 server control in
// the ControlCollection of the myForm server control.
// When a user clicks the button associated
// with this event handler, Radio3 is removed
// from the collection.
void RemoveBtn_Click(Object sender, EventArgs e) 
{
    if (myForm.get_Controls().Contains(Radio3)) {
        myForm.get_Controls().Remove(Radio3);
    }
} //RemoveBtn_Click

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ControlCollection-Klasse
ControlCollection-Member
System.Web.UI-Namespace
Control.Controls-Eigenschaft