ControlCollection.Remove(Control) 메서드

정의

부모 서버 컨트롤의 개체에서 지정된 서버 컨트롤 ControlCollection 을 제거합니다.

public:
 virtual void Remove(System::Web::UI::Control ^ value);
public virtual void Remove(System.Web.UI.Control value);
abstract member Remove : System.Web.UI.Control -> unit
override this.Remove : System.Web.UI.Control -> unit
Public Overridable Sub Remove (value As Control)

매개 변수

value
Control

제거할 서버 컨트롤입니다.

예제

다음 코드 예제에서는 이 메서드를 Remove 사용하여 서버 컨트롤에서 자식 컨트롤을 삭제합니다 myButton . 먼저 코드는 메서드를 Contains 사용하여 개체에 myChildControl 포함 ControlCollection 되는지 여부를 확인하고, 개체가 있는 경우 제거합니다.

// Use the Contains method to check whether
// a child control exists, and if it does,
// use the Remove method to delete it.        
if (myButton.Controls.Contains(myChildControl))
{
   myButton.Controls.Remove(myChildControl);
   msgRemove.Text = "You removed myLiteralControl.";
}
else msgRemove.Text="The control to remove does not exist." ;
' Use the Contains method to check whether
' a child control exists, and if it does,
' use the Remove method to delete it.        
If myButton.Controls.Contains(myChildControl)
   myButton.Controls.Remove(myChildControl)
   msgRemove.Text = "You removed myLiteralControl."
Else
   msgRemove.Text="The control to remove does not exist." 
End If

설명

인덱스 위치에서 컨트롤을 제거하려면 이 메서드를 RemoveAt 사용합니다.

적용 대상

추가 정보