本文整理汇总了C#中System.Web.UI.WebControls.ListItemCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.Remove方法的具体用法?C# ListItemCollection.Remove怎么用?C# ListItemCollection.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了ListItemCollection.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListItem
ListItem myListItem = new ListItem(Delete.Text.ToLower(),Delete.Text.ToLower());
// Check whether the 'ListItem' is present in the 'ListBox' or not.
if(ItemCollection.Contains(myListItem))
{
String deleteString=Delete.Text;
// Delete the listitem entered by the user in textfield.
ItemCollection.Remove(deleteString.ToLower());
Message.Text="<font color='green'><b>Deleted Successfully</b></font>";
}
else
{
Message.Text="<font color='red'><b>No ListItem with the given name is present in the ListBox for deletion.</b></font>";
}
示例2:
//Set the SelectedIndex to -1 so no items are selected.
// The new item will be set as the selected item when it is added.
DropDownList1.SelectedIndex = -1;
// Add the selected item to DropDownList1.
DropDownList1.Items.Add(ListBox1.SelectedItem);
// Delete the selected item from ListBox1.
ListBox1.Items.Remove(ListBox1.SelectedItem);