다음을 통해 공유


Control.Enabled 속성

정의

컨트롤이 사용자 상호 작용에 응답할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Enabled { bool get(); void set(bool value); };
public bool Enabled { get; set; }
member this.Enabled : bool with get, set
Public Property Enabled As Boolean

속성 값

컨트롤이 사용자 상호 작용에 응답할 수 있으면 기본값은 true입니다.

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예제에서는 그룹 상자 내에서 a TextBox 를 만들고 설정합니다 Location . 다음으로 그룹 상자의 속성을 설정하고 Text 그룹 상자를 폼의 맨 위에 도킹합니다. 마지막으로 그룹 상자에 포함된 모든 컨트롤을 사용하지 않도록 설정하는 속성을 false설정하여 그룹 상자를 사용하지 않도록 설정합니다Enabled.

   // Add a GroupBox to a form and set some of its common properties.
private:
   void AddMyGroupBox()
   {
      // Create a GroupBox and add a TextBox to it.
      GroupBox^ groupBox1 = gcnew GroupBox;
      TextBox^ textBox1 = gcnew TextBox;
      textBox1->Location = Point(15,15);
      groupBox1->Controls->Add( textBox1 );

      // Set the Text and Dock properties of the GroupBox.
      groupBox1->Text = "MyGroupBox";
      groupBox1->Dock = DockStyle::Top;

      // Disable the GroupBox (which disables all its child controls)
      groupBox1->Enabled = false;

      // Add the Groupbox to the form.
      this->Controls->Add( groupBox1 );
   }
// Add a GroupBox to a form and set some of its common properties.
private void AddMyGroupBox()
{
   // Create a GroupBox and add a TextBox to it.
   GroupBox groupBox1 = new GroupBox();
   TextBox textBox1 = new TextBox();
   textBox1.Location = new Point(15, 15);
   groupBox1.Controls.Add(textBox1);

   // Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox";
   groupBox1.Dock = DockStyle.Top;

   // Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = false;

   // Add the Groupbox to the form.
   this.Controls.Add(groupBox1);
}
' Add a GroupBox to a form and set some of its common properties.
Private Sub AddMyGroupBox()
   ' Create a GroupBox and add a TextBox to it.
   Dim groupBox1 As New GroupBox()
   Dim textBox1 As New TextBox()
   textBox1.Location = New Point(15, 15)
   groupBox1.Controls.Add(textBox1)
   
   ' Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox"
   groupBox1.Dock = DockStyle.Top
   
   ' Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = False
   
   ' Add the Groupbox to the form.
   Me.Controls.Add(groupBox1)
End Sub

설명

Enabled 속성을 사용하면 런타임에 컨트롤을 사용하거나 사용하지 않도록 설정할 수 있습니다. 예를 들어 애플리케이션의 현재 상태에 적용되지 않는 컨트롤을 사용하지 않도록 설정할 수 있습니다. 컨트롤을 사용하지 않도록 설정하여 사용을 제한할 수도 있습니다. 예를 들어 사용자가 단추를 클릭하지 못하도록 단추를 사용하지 않도록 설정할 수 있습니다. 컨트롤을 사용하지 않도록 설정하면 선택할 수 없습니다.

중요합니다

Enabled 속성을 설정해 false 도 애플리케이션의 제어 상자가 비활성화되거나 애플리케이션 창에서 포커스가 수신되지 않습니다.

컨테이너 컨트롤에 활성화된 속성이 설정된 경우 포함된 모든 컨트롤도 사용하지 않도록 설정 false됩니다. 예를 들어 사용자가 사용 GroupBox 안 함 컨트롤에 포함된 컨트롤을 클릭하면 이벤트가 발생하지 않습니다.

메모

스크롤 가능한 컨트롤을 사용하지 않도록 설정하면 스크롤 막대도 비활성화됩니다. 예를 들어 비활성화된 여러 줄 텍스트 상자를 스크롤하여 모든 텍스트 줄을 표시할 수 없습니다.

적용 대상

추가 정보