Form.ControlCollection クラス

定義

フォーム上のコントロールのコレクションを表します。

public: ref class Form::ControlCollection : System::Windows::Forms::Control::ControlCollection
public class Form.ControlCollection : System.Windows.Forms.Control.ControlCollection
[System.Runtime.InteropServices.ComVisible(false)]
public class Form.ControlCollection : System.Windows.Forms.Control.ControlCollection
type Form.ControlCollection = class
    inherit Control.ControlCollection
[<System.Runtime.InteropServices.ComVisible(false)>]
type Form.ControlCollection = class
    inherit Control.ControlCollection
Public Class Form.ControlCollection
Inherits Control.ControlCollection
継承
Form.ControlCollection
継承
属性

次のコード例では、フォームのコントロール コレクションに TextBox コントロールと Label コントロールを追加します。 この例では、フォームが作成され、 Form1という名前が付けられている必要があります。

public:
   void AddMyControls()
   {
      TextBox^ textBox1 = gcnew TextBox;
      Label^ label1 = gcnew Label;
      
      // Initialize the controls and their bounds.
      label1->Text = "First Name";
      label1->Location = Point( 48, 48 );
      label1->Size = System::Drawing::Size( 104, 16 );
      textBox1->Text = "";
      textBox1->Location = Point(48,64);
      textBox1->Size = System::Drawing::Size( 104, 16 );
      
      // Add the TextBox control to the form's control collection.
      Controls->Add( textBox1 );
      // Add the Label control to the form's control collection.
      Controls->Add( label1 );
   }
public void AddMyControls()
 {
    TextBox textBox1 = new TextBox();
    Label label1 = new Label();
    
    // Initialize the controls and their bounds.
    label1.Text = "First Name";
    label1.Location = new Point(48,48);
    label1.Size = new Size (104, 16);
    textBox1.Text = "";
    textBox1.Location = new Point(48, 64);
    textBox1.Size = new Size(104,16);
 
    // Add the TextBox control to the form's control collection.
    Controls.Add(textBox1);
    // Add the Label control to the form's control collection.
    Controls.Add(label1);
 }
Public Sub AddMyControls()
    Dim textBox1 As New TextBox()
    Dim label1 As New Label()
    
    ' Initialize the controls and their bounds.
    label1.Text = "First Name"
    label1.Location = New Point(48, 48)
    label1.Size = New Size(104, 16)
    textBox1.Text = ""
    textBox1.Location = New Point(48, 64)
    textBox1.Size = New Size(104, 16)
    
    ' Add the TextBox control to the form's control collection.
    Controls.Add(textBox1)
    ' Add the Label control to the form's control collection.
    Controls.Add(label1)
End Sub

注釈

このクラスは、フォーム内に含まれるコントロールのコレクションを表します。 Add メソッドを使用してフォームにコントロールを追加し、Remove メソッドを使用してフォームからコントロールを削除できます。 このクラスで表されるコントロール コレクションは、特定のフォームにバインドしないと作成できません。 その結果、このコントロール コレクションの複数のインスタンスを作成し、それらをアクティブなフォームと交換して、異なるコントロール レイアウトを提供することはできません。

コンストラクター

名前 説明
Form.ControlCollection(Form)

Form.ControlCollection クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
Count

コレクションに含まれる要素の数を取得します。

(継承元 Control.ControlCollection)
IsReadOnly

このコレクション オブジェクトが読み取り専用かどうかを示す値を取得します。

(継承元 Control.ControlCollection)
Item[Int32]

コレクション内の指定したインデックス位置にある Control を示します。

(継承元 Control.ControlCollection)
Item[String]

コレクション内の指定したキーを持つ Control を示します。

(継承元 Control.ControlCollection)
Owner

この Control.ControlCollectionを所有するコントロールを取得します。

(継承元 Control.ControlCollection)

メソッド

名前 説明
Add(Control)

フォームにコントロールを追加します。

AddRange(Control[])

コントロール オブジェクトの配列をコレクションに追加します。

(継承元 Control.ControlCollection)
Clear()

コレクションからすべてのコントロールを削除します。

(継承元 Control.ControlCollection)
Contains(Control)

指定したコントロールがコレクションのメンバーであるかどうかを判断します。

(継承元 Control.ControlCollection)
ContainsKey(String)

指定したキーを持つ項目が Control.ControlCollection に含まれているかどうかを判断します。

(継承元 Control.ControlCollection)
CopyTo(Array, Int32)

コレクションの要素を、特定の配列インデックスから始まる配列にコピーします。

(継承元 Control.ControlCollection)
Equals(Object)

現在のコレクション オブジェクトと指定したオブジェクトが等しいかどうかを指定します。

(継承元 Control.ControlCollection)
Find(String, Boolean)

Name プロパティでコントロールを検索し、一致するすべてのコントロールの配列を作成します。

(継承元 Control.ControlCollection)
GetChildIndex(Control, Boolean)

コントロール コレクション内の指定した子コントロールのインデックスを取得し、指定したコントロールがコントロール コレクション内にない場合は、必要に応じて例外を発生させます。

(継承元 Control.ControlCollection)
GetChildIndex(Control)

コントロール コレクション内の指定した子コントロールのインデックスを取得します。

(継承元 Control.ControlCollection)
GetEnumerator()

Control.ControlCollectionを反復処理するために使用される列挙子オブジェクトへの参照を取得します。

(継承元 Control.ControlCollection)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Control.ControlCollection)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IndexOf(Control)

コントロール コレクション内の指定したコントロールのインデックスを取得します。

(継承元 Control.ControlCollection)
IndexOfKey(String)

コレクション内の指定した項目の最初の出現位置のインデックスを取得します。

(継承元 Control.ControlCollection)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
Remove(Control)

フォームからコントロールを削除します。

RemoveAt(Int32)

指定したインデックス位置にあるコントロール コレクションからコントロールを削除します。

(継承元 Control.ControlCollection)
RemoveByKey(String)

指定したキーを持つ子コントロールを削除します。

(継承元 Control.ControlCollection)
SetChildIndex(Control, Int32)

コレクション内の指定した子コントロールのインデックスを、指定したインデックス値に設定します。

(継承元 Control.ControlCollection)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

名前 説明
ICloneable.Clone()

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 Clone()を参照してください。

(継承元 Control.ControlCollection)
ICollection.IsSynchronized

このメンバーの説明については、 IsSynchronized プロパティを参照してください。

(継承元 ArrangedElementCollection)
ICollection.SyncRoot

このメンバーの説明については、 SyncRoot プロパティを参照してください。

(継承元 ArrangedElementCollection)
IList.Add(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 Add(Object)を参照してください。

(継承元 Control.ControlCollection)
IList.Clear()

このメンバーの説明については、 Clear() メソッドを参照してください。

(継承元 ArrangedElementCollection)
IList.Contains(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 Contains(Object)を参照してください。

(継承元 Control.ControlCollection)
IList.IndexOf(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 IndexOf(Object)を参照してください。

(継承元 Control.ControlCollection)
IList.Insert(Int32, Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 Insert(Int32, Object)を参照してください。

(継承元 Control.ControlCollection)
IList.IsFixedSize

このメンバーの説明については、 IsFixedSize プロパティを参照してください。

(継承元 ArrangedElementCollection)
IList.Item[Int32]

このメンバーの説明については、 Item[Int32] プロパティを参照してください。

(継承元 ArrangedElementCollection)
IList.Remove(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

このメンバーの説明については、 Remove(Object)を参照してください。

(継承元 Control.ControlCollection)
IList.RemoveAt(Int32)

このメンバーの説明については、 RemoveAt(Int32) メソッドを参照してください。

(継承元 ArrangedElementCollection)

拡張メソッド

名前 説明
AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryableに変換します。

Cast<TResult>(IEnumerable)

IEnumerable の要素を指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定した型に基づいて、IEnumerable の要素をフィルター処理します。

適用対象

こちらもご覧ください