TopIndex Property

See Also1DQ4YJP                 Example2T8LK6>Low

Applies To

File list box1M6S8UX, list boxG11UCK.

Description

Determines which item in a file list box or list box appears in the topmost position.  The default is 0, or the first item in the list.  Not available at design time.

Usage

[form.]{ filelistbox|listbox}.TopIndex[ = numericexpression ]

Remarks

Use this property to scroll through a file list box or list box without selecting an item.

If the Columns008IIH property is set to 0, the item appears at the topmost position if there are enough items below it to fill the visible portion of the list.

If Columns is greater than 0, the item's column moves to the leftmost position without changing its position within the column.

Data Type

IntegerDOKXHY


See Also

Help:

AddItem Method2BIX3OB

Clear MethodPMJHM6

List PropertyBKCX6E

ListCount Property4E91QN

MultiSelect PropertyYICVLQ

NewIndex PropertyIOGOXY

RemoveItem MethodM867OS

Selected PropertyKC8D7W

 

Programmer's Guide:

Chapter 3, "Creating and Using Controls"


TopIndex Property Example

The example fills a list box with names of screen fonts and then scrolls through the list box when you click the form.  To try this example, paste the code into the Declarations section of a form that contains a list box.  Then press F5 and click the form.

Sub Form_Load ()
  Dim I                                  ' Declare variable.
  For I = 0 To Screen.FontCount -1       ' Fill list box with
    List1.AddItem Screen.Fonts(I)        ' screen font names.
  Next I
End Sub


Sub Form_Click ()
  Dim X                                  ' Declare variable.
  X = List1.TopIndex                     ' Get current index.
  List1.TopIndex = List1.TopIndex + 5    ' Reset topmost item.
  If List1.TopIndex = X Then List1.TopIndex = 0
End Sub