ListItemCollection Constructeur

Définition

Initialise une nouvelle instance de la classe ListItemCollection.

public:
 ListItemCollection();
public ListItemCollection();
Public Sub New ()

Exemples

L’exemple de code suivant illustre la création ListItemCollection d’objets, l’ajout d’éléments aux collections et la suppression d’éléments des collections. Pour afficher ce code dans un exemple entièrement opérationnel, consultez la WebControl rubrique de classe.

// 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()

Remarques

Utilisez ce constructeur pour créer et initialiser une nouvelle instance de la classe à l’aide ListItemCollection de valeurs par défaut.

S’applique à