Control.ControlCollection.AddRange メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Control.ControlCollection.AddRange メソッドの意味・解説 

Control.ControlCollection.AddRange メソッド

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

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

解説解説
使用例使用例

2 つControl オブジェクト派生クラス Panel の Control.ControlCollection に追加するコード例次に示します。この例では、Form 上に Panel コントロールButton コントロール作成されている必要がありますボタンクリックされると、2 つRadioButton コントロールパネルControl.ControlCollection追加されます。

' Create two RadioButtons to add to the Panel.
Dim RadioAddButton As RadioButton = New
 RadioButton()
Dim RadioAddRangeButton As RadioButton = New
 RadioButton()

' Add controls to the Panel using the AddRange method.
Private Sub AddRangeButton_Click(ByVal
 sender As System.Object, _
    ByVal e As System.EventArgs) Handles
 AddRangeButton.Click
    ' Set the Text the RadioButtons will display.
    RadioAddButton.Text = "RadioAddButton"
    RadioAddRangeButton.Text = "RadioAddRangeButton"

    ' Set the appropriate location of RadioAddRangeButton.
    RadioAddRangeButton.Location = New System.Drawing.Point( _
    RadioAddButton.Location.X, _
    RadioAddButton.Location.Y + RadioAddButton.Height)

    ' Add the controls to the Panel.
    Panel1.Controls.AddRange(New Control() {RadioAddButton, RadioAddRangeButton})
End Sub
// Create two RadioButtons to add to the Panel.
private RadioButton radioAddButton = new RadioButton();
private RadioButton radioRemoveButton = new
 RadioButton();

// Add controls to the Panel using the AddRange method.
private void addRangeButton_Click(object sender,
 System.EventArgs e)
{
   // Set the Text the RadioButtons will display.
   radioAddButton.Text = "radioAddButton";
   radioRemoveButton.Text = "radioRemoveButton";
            
   // Set the appropriate location of radioRemoveButton.
   radioRemoveButton.Location = new System.Drawing.Point(
     radioAddButton.Location.X, 
     radioAddButton.Location.Y + radioAddButton.Height);
            
   //Add the controls to the Panel.
   panel1.Controls.AddRange(new Control[]{radioAddButton, radioRemoveButton});
}
   // Create two RadioButtons to add to the Panel.
private:
   RadioButton^ radioAddButton;
   RadioButton^ radioRemoveButton;

   // Add controls to the Panel using the AddRange method.
   void addRangeButton_Click( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      radioAddButton = gcnew RadioButton;
      radioRemoveButton = gcnew RadioButton;
      
      // Set the Text the RadioButtons will display.
      radioAddButton->Text = "radioAddButton";
      radioRemoveButton->Text = "radioRemoveButton";
      
      // Set the appropriate location of radioRemoveButton.
      radioRemoveButton->Location = System::Drawing::Point( radioAddButton->Location.X,
 radioAddButton->Location.Y + radioAddButton->Height );
      
      //Add the controls to the Panel.
      array<Control^>^controlArray = {radioAddButton,radioRemoveButton};
      panel1->Controls->AddRange( controlArray );
   }
// Create two RadioButtons to add to the Panel.
private RadioButton radioAddButton = new RadioButton();
private RadioButton radioRemoveButton = new
 RadioButton();

// Add controls to the Panel using the AddRange method.
private void addRangeButton_Click(Object sender,
 System.EventArgs e)
{
    // Set the Text the RadioButtons will display.
    radioAddButton.set_Text("radioAddButton");
    radioRemoveButton.set_Text("radioRemoveButton");

    // Set the appropriate location of radioRemoveButton.
    radioRemoveButton.set_Location(new System.Drawing.Point(radioAddButton.
        get_Location().get_X(), radioAddButton.get_Location().get_Y() 
        + radioAddButton.get_Height()));

    //Add the controls to the Panel.
    panel1.get_Controls().AddRange(new Control[] { radioAddButton,
 
        radioRemoveButton });
} //addRangeButton_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Control.ControlCollection クラス
Control.ControlCollection メンバ
System.Windows.Forms 名前空間
Add



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

辞書ショートカット

すべての辞書の索引

「Control.ControlCollection.AddRange メソッド」の関連用語

Control.ControlCollection.AddRange メソッドのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS