17 February 2014

List Item Collections -Basic Web Controls

        The ListItemCollection object is a collection of List Item objects. Each List Item object represents one item in the list. Items in a ListItemCollection are numbered from 0.
       When the items into a list box are loaded using strings like: lstcolor.Items.Add("Blue") . then both the Text and Value properties of the list item are set to the string value you specify. To set it differently you must create a list item object and then add that item to the collection.
       The List Item Collection Editor is used to add item to a drop-down list or list box. This is used to create a static list of items. To display the Collection Editor select Edit item from the smart tag menu, or select the control and then click the ellipsis button from the Item property in the Properties window.
Common Properties of List Item Collection:
       Item(Integer): A List Item object that represents the item at the specified index
       Count : The number of items in the collection 
Common methods of List Item Collection:
        Add(String): Adds a new item to the end of the collection and assigns the string parameter  to the text property of the item 

        Add(List Item):Adds new item to the end of the collection
     Insert(integer,string):Inserts an item at the specified index location in the collection,and assigns the string parameter to the text property of the item 
      Insert(integer,List Item):Inserts the item at the specified index location in the collection
   
      Remove(String): Removes he item with the text value same as the string 
       
      RemoveAt(Integer): Removes the item at the specified index as the integer
   
      Clear :Removes all the items of the collection
  
      FindByValue(String): Returns the item whose value is same as the string 
  
      FindByValue(Text):Returns the item  whose text is same as the string 

No comments:

Post a Comment