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

속성 값

Boolean

컨트롤이 사용자 상호 작용에 응답할 수 있으면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예에서는 만듭니다는 TextBox 설정 및 해당 Location 그룹 상자 내에서. 그런 다음 설정의 Text 그룹 상자 및 폼의 위쪽에 도킹 된 그룹 상자는 속성입니다. 마지막으로, 그룹 상자를 설정 하 여 비활성화 된 Enabled 속성을 false, 사용 하지 않도록 설정할 그룹 상자 내에 포함 된 모든 컨트롤에 이르게 합니다.

   // 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 컨트롤에 포함된 컨트롤을 클릭하면 이벤트가 발생하지 않습니다.

참고

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

적용 대상

추가 정보