Control.Enabled プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

/** @property */ public boolean get_Enabled () /** @property */ public void set_Enabled (boolean value)
コントロールがユーザーとの対話に応答できる場合は 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.Enabled プロパティを検索する場合は、下記のリンクをクリックしてください。

- Control.Enabled プロパティのページへのリンク