ControlCollection.Contains(Control) Método

Definición

Determina si el control de servidor especificado está en el objeto ControlCollection del control de servidor principal.Determines whether the specified server control is in the parent server control's ControlCollection object.

public:
 virtual bool Contains(System::Web::UI::Control ^ c);
public virtual bool Contains (System.Web.UI.Control c);
abstract member Contains : System.Web.UI.Control -> bool
override this.Contains : System.Web.UI.Control -> bool
Public Overridable Function Contains (c As Control) As Boolean

Parámetros

c
Control

Control de servidor que se va a buscar en la colección.The server control to search for in the collection.

Devoluciones

Boolean

Es true si el control de servidor especificado existe en la colección; en caso contrario, es false.true if the specified server control exists in the collection; otherwise, false.

Ejemplos

// 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.
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

Se aplica a

Consulte también