ListItemCollection.Add Method
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.
Appends a ListItem to the end of the collection.
Overloads
Add(String) |
Appends a ListItem to the end of the collection that represents the specified string. |
Add(ListItem) |
Appends the specified ListItem to the end of the collection. |
Add(String)
Appends a ListItem to the end of the collection that represents the specified string.
public:
void Add(System::String ^ item);
public void Add (string item);
member this.Add : string -> unit
Public Sub Add (item As String)
Parameters
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 the Add method to append a ListItem to the end of the collection. This implementation of the method creates a ListItem to represent the text specified by the item
parameter. This ListItem is then appended to the collection.
See also
Applies to
Add(ListItem)
Appends the specified ListItem to the end of the collection.
public:
void Add(System::Web::UI::WebControls::ListItem ^ item);
public void Add (System.Web.UI.WebControls.ListItem item);
member this.Add : System.Web.UI.WebControls.ListItem -> unit
Public Sub Add (item As ListItem)
Parameters
Remarks
Use the Add method to append a ListItem to the end of the collection. This implementation of the method takes the ListItem specified by the item
parameter and appends it to the collection.
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기