Unselect (Method)

Applies To:

ControlsListBox

Description:

Deselects objects in list boxes.

Syntax:

Expression.Unselect(Index As Number)

Note:

Index is the nth item in the ListBox (index based 1).

Expression Required:

An expression that deselects a list box object

Dependency:

The MultiSelect (Property) must be enabled for the list box object in order to use this method.

Example:

In the following example, a list box was populated with four values, These values can be selected and counted in a text box. The Unselect method was added for each of the four values and any out of bound values:

//Selects all values in ListBox1 and performs a count
var cnt = ListBox1.Count
for (var i = 1; i <= cnt; i++)
{
ListBox1.Select(i)
}
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects first index value in ListBox1
ListBox1.Unselect(1)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects second index value in ListBox1
ListBox1.Unselect(2)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects third index value in ListBox1
ListBox1.Unselect(3)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects fourth index value in ListBox1
ListBox1.Unselect(4)
TextBox1.Text=ListBox1.SelectedList.Count