다음을 통해 공유


ControlCollection.Contains(Control) 메서드

정의

지정된 서버 컨트롤이 부모 서버 컨트롤의 ControlCollection 개체에 있는지 여부를 확인합니다.

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

매개 변수

c
Control

컬렉션에서 검색할 서버 컨트롤입니다.

반환

Boolean

지정된 서버 컨트롤이 컬렉션에 있으면 true이고, 그렇지 않으면 false입니다.

예제

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

적용 대상

추가 정보