ListItemCollection.AddRange メソッド
アセンブリ: System.Web (system.web.dll 内)


AddRange メソッドを使用して、items パラメータで指定した ListItem オブジェクトの配列の項目を追加します。これにより、複数の ListItem オブジェクトを 1 回の操作でコレクションに追加できます。

Dim MyListItemCollection As ListItemCollection = New ListItemCollection() ' Dimensions an array of ListItems that are used to populate the collection. Dim NewListItemArray(TempDataTable.Count - 1) As System.Web.UI.WebControls.ListItem ' Populates the array of ListItems with generic data. Dim i As Integer For i = 0 To TempDataTable.Count - 1 NewListItemArray(i) = New ListItem() NewListItemArray(i).Text = "Item " + i.ToString() NewListItemArray(i).Value = i.ToString() Next ' Adds an entire array of ListItem objects to the collection. MyListItemCollection.AddRange(NewListItemArray)
ListItemCollection myListItemCollection = new ListItemCollection(); // Creates an array of ListItems that are used to populate the collection. System.Web.UI.WebControls.ListItem[] newListItemArray = new ListItem[tempDataTable.Count]; // Populates the array of ListItems with generic data. for (int i=0; i < tempDataTable.Count; i++) { newListItemArray[i] = new ListItem(); newListItemArray[i].Text = "Item " + i.ToString(); newListItemArray[i].Value = i.ToString(); } // Adds an entire array of ListItem objects to the collection. myListItemCollection.AddRange(newListItemArray);
ListItemCollection myListItemCollection = new ListItemCollection(); // Creates an array of ListItems that are used to populate // the collection. System.Web.UI.WebControls.ListItem newListItemArray[] = new ListItem[tempDataTable.get_Count()]; // Populates the array of ListItems with generic data. for (int i = 0; i < tempDataTable.get_Count(); i++) { newListItemArray.set_Item(i, new ListItem()); newListItemArray[i].set_Text("Item " + Convert.ToString(i)); newListItemArray[i].set_Text("Item " + Convert.ToString(i)); newListItemArray[i].set_Value(Convert.ToString(i)); } // Adds an entire array of ListItem objects to the collection. myListItemCollection.AddRange(newListItemArray);

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListItemCollection.AddRange メソッドを検索する場合は、下記のリンクをクリックしてください。

- ListItemCollection.AddRange メソッドのページへのリンク