다음을 통해 공유


Control.Enabled 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Property Enabled As Boolean
‘사용 방법
Dim instance As Control
Dim value As Boolean

value = instance.Enabled

instance.Enabled = value
[LocalizableAttribute(true)] 
public bool Enabled { get; set; }
[LocalizableAttribute(true)] 
public:
property bool Enabled {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_Enabled ()

/** @property */
public void set_Enabled (boolean value)
public function get Enabled () : boolean

public function set Enabled (value : boolean)

속성 값

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

설명

Enabled 속성을 사용하면 런타임에서 컨트롤을 활성화하거나 비활성화할 수 있습니다. 예를 들어, 응용 프로그램의 현재 상태에 적용되지 않는 컨트롤을 비활성화할 수 있습니다. 또한 컨트롤을 사용할 수 없도록 해당 컨트롤을 비활성화할 수도 있습니다. 예를 들어, 클릭할 수 없도록 단추를 비활성화할 수 있습니다. 비활성화된 컨트롤은 선택할 수 없습니다.

중요

Enabled 속성을 false로 설정해도 응용 프로그램의 컨트롤 상자가 비활성화되지 않으며 응용 프로그램 창에서 포커스를 받을 수 있습니다.

컨테이너 컨트롤의 활성화된 속성을 false로 설정하면 포함된 모든 컨트롤도 비활성화됩니다. 예를 들어, 비활성화된 GroupBox 컨트롤에 포함된 특정 컨트롤을 클릭하더라도 이벤트가 발생하지 않습니다.

참고

스크롤할 수 있는 컨트롤을 비활성화하면 스크롤 막대도 비활성화됩니다. 예를 들어, 비활성화된 여러 줄 텍스트 상자에서는 스크롤하여 모든 텍스트 줄을 표시할 수 없습니다.

예제

다음 코드 예제에서는 GroupBox를 만들고 해당 공용 속성 중 일부를 설정합니다. 이 예제에서는 TextBox를 만든 다음 텍스트 상자의 Location을 그룹 상자 내에 설정합니다. 다음에는 그룹 상자의 Text 속성을 설정하고 폼의 상단에 그룹 상자를 도킹시킵니다. 마지막으로 Enabled 속성을 false로 설정하여 그룹 상자를 비활성화합니다. 이렇게 하면 그룹 상자에 포함된 모든 컨트롤도 비활성화됩니다.

' 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
// 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:
   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.set_Location(new Point(15, 15));
    groupBox1.get_Controls().Add(textBox1);
    // Set the Text and Dock properties of the GroupBox.
    groupBox1.set_Text("MyGroupBox");
    groupBox1.set_Dock(DockStyle.Top);
    // Disable the GroupBox (which disables all its child controls)
    groupBox1.set_Enabled(false);
    // Add the Groupbox to the form.
    this.get_Controls().Add(groupBox1);
} //AddMyGroupBox

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
ScrollableControl