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 ListItem 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:
Property
|
Description
|
Item(integer)
|
A ListItem object that represents the item at the
specified index.
|
Count
|
The number of items in the collection.
|
Methods
|
Description
|
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(ListItem)
|
Adds a 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, ListItem)
|
Inserts the item at the specified index location in the
collection.
|
Remove(string)
|
Removes the item with the Text value same as the string.
|
Remove(ListItem)
|
Removes the specified item.
|
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.
|
Comments
Post a Comment