ListItemCollection Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the ListItemCollection class.
public:
ListItemCollection();
public ListItemCollection ();
Public Sub New ()
Examples
The following code example demonstrates creating ListItemCollection objects, adding items to the collections, and removing items from the collections. To view this code in a fully working example, see the WebControl class topic.
// Create a new ListItemCollection.
ListItemCollection listBoxData = new ListItemCollection();
// Add items to the collection.
listBoxData.Add(new ListItem("apples"));
listBoxData.Add(new ListItem("bananas"));
listBoxData.Add(new ListItem("cherries"));
listBoxData.Add("grapes");
listBoxData.Add("mangos");
listBoxData.Add("oranges");
// Set the ListItemCollection as the data source for ListBox1.
ListBox1.DataSource = listBoxData;
ListBox1.DataBind();
' Create a new ListItemCollection.
Dim listBoxData As New ListItemCollection()
' Add items to the collection.
listBoxData.Add(New ListItem("apples"))
listBoxData.Add(New ListItem("bananas"))
listBoxData.Add(New ListItem("cherries"))
listBoxData.Add("grapes")
listBoxData.Add("mangos")
listBoxData.Add("oranges")
' Set the ListItemCollection as the data source for ListBox1.
ListBox1.DataSource = listBoxData
ListBox1.DataBind()
Remarks
Use this constructor to create and initialize a new instance of the ListItemCollection class using default values.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET