Control.Controls 속성

정의

컨트롤에 포함된 컨트롤의 컬렉션을 가져옵니다.

public:
 property System::Windows::Forms::Control::ControlCollection ^ Controls { System::Windows::Forms::Control::ControlCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Control.ControlCollection Controls { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Controls : System.Windows.Forms.Control.ControlCollection
Public ReadOnly Property Controls As Control.ControlCollection

속성 값

컨트롤에 포함된 컨트롤의 컬렉션을 나타내는 Control.ControlCollection입니다.

특성

예제

다음 코드 예제에서는 제거 합니다 ControlControl.ControlCollection 파생된 클래스 Panel 의 멤버인 경우는 컬렉션입니다. 이 예제에서는 에서 , Button및 하나 이상의 RadioButton 컨트롤을 만들어야 Panel합니다Form. 컨트롤이 RadioButton 컨트롤에 Panel 추가되고 컨트롤이 PanelForm추가됩니다. 단추를 클릭하면 라는 removeButton 라디오 단추가 에서 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 컨트롤 컬렉션의 부모 역할을 할 수 있습니다. 예를 들어 여러 컨트롤이 에 Form추가되면 각 컨트롤은 클래스에서 Control 파생된 폼의 Control.ControlCollection 속성에 Controls 할당된 의 멤버입니다.

클래스에서 사용할 수 있는 Control.ControlCollection 메서드를 사용하여 속성에 할당된 Controls 의 컨트롤을 Control.ControlCollection 조작할 수 있습니다.

부모 컨트롤에 여러 컨트롤을 추가할 때 추가할 컨트롤을 SuspendLayout 초기화하기 전에 메서드를 호출하는 것이 좋습니다. 부모 컨트롤에 컨트롤을 추가한 후 메서드를 호출합니다 ResumeLayout . 이렇게 하면 많은 컨트롤을 사용 하 여 애플리케이션의 성능을 향상 시킵니다.

사용 된 Controls 중첩 된 컨트롤을 포함 하 여 폼의 모든 컨트롤을 반복 하는 속성입니다. 메서드를 GetNextControl 사용하여 탭 순서에서 이전 또는 다음 자식 컨트롤을 검색합니다. 사용 된 ActiveControl 속성을 가져오기 또는 컨테이너 컨트롤의 활성 컨트롤을 설정 합니다.

적용 대상

추가 정보