Control.ControlCollection.Remove(Control) 메서드

정의

컨트롤 컬렉션에서 지정된 컨트롤을 제거합니다.

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

매개 변수

value
Control

Control에서 제거할 Control.ControlCollection입니다.

예제

다음 코드 예제에서는 컬렉션의 멤버인 경우 파생 클래스 Panel 에서 Control.ControlCollection 제거 Control 합니다. 이 예제에서는 에 대해 하나 이상의 컨트롤을 만들어야 PanelButton합니다Form.RadioButton 컨트롤이 RadioButton 컨트롤에 Panel 추가되고 컨트롤이 Panel 에 추가 Form됩니다. 단추를 클릭하면 이름이 지정된 radioButton2 라디오 단추가 제거 Control.ControlCollection됩니다.

   // Remove the RadioButton control if it exists.
private:
   void removeButton_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      if ( panel1->Controls->Contains( removeButton ) )
      {
         panel1->Controls->Remove( removeButton );
      }
   }
// Remove the RadioButton control if it exists.
private void removeButton_Click(object sender, System.EventArgs e)
{
   if(panel1.Controls.Contains(removeButton))
   {
      panel1.Controls.Remove(removeButton);
   }
}
' Remove the RadioButton control if it exists.
Private Sub RemoveButton_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles RemoveButton.Click
    If Panel1.Controls.Contains(RemoveButton) Then
        Panel1.Controls.Remove(RemoveButton)
    End If
End Sub

설명

Control 컨트롤 컬렉션에서 제거 되는 경우 모든 후속 컨트롤 컬렉션에서 한 위치 위로 이동 됩니다.

제거할 수도 있습니다는 Control 를 사용 하 여 합니다 RemoveAt 메서드 또는 모든 제어를 사용 하 여 제거를 Clear 메서드.

새로 추가 하려면 Control 컬렉션에 개체를 사용 합니다 Add 또는 AddRange 메서드.

상속자 참고

파생 클래스에서 재정의하는 Remove(Control) 경우 기본 클래스의 Remove(Control) 메서드를 호출하여 컨트롤이 컬렉션에서 제거되었는지 확인해야 합니다.

적용 대상

추가 정보