SetState

Description

Sets the highlighted state of an item in a list box. SetState is only applicable to a list box control whose MultiSelect property is set to true.

Applies to

ListBox and PictureListBox controls

Syntax

listboxname.SetState ( index, state )

Argument

Description

listboxname

The name of the ListBox or PictureListBox in which you want to set the state (highlighted or not highlighted) for an item. The MultiSelect property for the control must be set to true.

index

The number of the item for which you want to set the state. Specify 0 to set the state of all the items in the ListBox.

state

A boolean value that determines the state of the item:

  • TRUE -- Selected

  • FALSE -- Not selected


Return value

Integer.

Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is null, SetState returns null.

Usage

When the MultiSelect property for the control is false, use SelectItem, instead of SetState, to select one item at a time.

Examples

This statement turns on the highlight for item 6 in lb_Actions:

lb_Actions.SetState(6, TRUE)

This statement deselects all items in lb_Actions:

lb_Actions.SetState(0, FALSE)

This statement turns off the highlight for item 6 in lb_Actions if it is selected and turns it on again if it is not selected:

IF lb_Actions.State(6) = 1 THEN
      lb_Actions.SetState(6, FALSE)
ELSE
      lb_Actions.SetState(6, TRUE)
END IF

See also

SelectItem

SetTop

State