Control.Controlsとは? わかりやすく解説

Control.Controls プロパティ

UI 階層構造指定されサーバー コントロールの子コントロールを表す ControlCollection オブジェクト取得します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overridable ReadOnly
 Property Controls As ControlCollection
Dim instance As Control
Dim value As ControlCollection

value = instance.Controls
public virtual ControlCollection Controls { get;
 }
public:
virtual property ControlCollection^ Controls {
    ControlCollection^ get ();
}
/** @property */
public ControlCollection get_Controls ()
public function get Controls
 () : ControlCollection

プロパティ
指定されサーバー コントロールの子コントロールコレクション

解説解説

ASP.NET ページでは、サーバー コントロール開始タグ終了タグの間でコントロール宣言して追加すると、ASP.NET自動的にそのコントロールを、格納する側のサーバー コントロールControlCollection追加しますサーバー処理されない HTML タグまたは文字列は LiteralControl オブジェクトとして扱われます。これらは、他のサーバー コントロール同様にコレクション追加されます。

Controls プロパティは、任意のサーバー コントロールControlCollection クラスプログラムによりアクセスできるようにします。コントロールコレクション追加したり、コレクションから削除できますまた、コレクションサーバー コントロール反復処理できます

継承時の注意 Controls プロパティオーバーライドするときは、必ず EnsureChildControls メソッド呼び出してください。さらに、プログラムによってコントロール コレクションコントロール追加することを計画している場合は、オーバーライドされた CreateChildControls メソッドコントロール追加することを検討してください

使用例使用例

Controls プロパティ通じてサーバー コントロールControlCollection オブジェクトに子コントロール追加する方法次の例に示します

Controls.Add(New LiteralControl("<h3>Value:
 "))
  
Controls.Add(new LiteralControl("<h3>Value: "));
get_Controls().Add(new LiteralControl("<h3>Value: "));
Controls.Add(new LiteralControl("<h3>Value: "));
pt]
this.Controls.Add(new LiteralControl("<h3>Value:
 "));
   
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Control クラス
Control メンバ
System.Web.UI 名前空間
ControlCollection
CreateControlCollection
CreateChildControls

Control.Controls プロパティ

コントロール内に格納されているコントロールコレクション取得します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As Control
Dim value As ControlCollection

value = instance.Controls
public ControlCollection Controls { get; }
public:
property ControlCollection^ Controls {
    ControlCollection^ get ();
}
/** @property */
public ControlCollection get_Controls ()
public function get Controls
 () : ControlCollection

プロパティ
コントロール内に格納されているコントロールコレクションを表す Control.ControlCollection。

解説解説
使用例使用例

Control派生クラス PanelControl.ControlCollectionメンバである場合に、そのコントロールコレクションから削除するコード例次に示します。この例では、Form 上に PanelButton、および少なくとも 1 つRadioButton コントロール作成されている必要がありますRadioButton コントロールPanel コントロール追加されPanel コントロールForm コントロール追加されます。ボタンクリックされると、radioButton2 という名前のオプション ボタンControl.ControlCollection から削除されます。

' 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(RadioAddRangeButton) Then
        Panel1.Controls.Remove(RadioAddRangeButton)
    End If
End Sub
// 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 void removeButton_Click(Object sender,
 System.EventArgs e)
{
    if (panel1.get_Controls().Contains(removeButton)) {
        panel1.get_Controls().Remove(removeButton);
    }
} //removeButton_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Control クラス
Control メンバ
System.Windows.Forms 名前空間
Control.ControlCollection
CreateControlsInstance
SuspendLayout
ResumeLayout



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Control.Controls」の関連用語

Control.Controlsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Control.Controlsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS