Home > Language Reference > Classes > List

EnsureVisible Method

Ensures that an element is visible by scrolling - if necessary - the contents of the list.

Syntax

Public Sub EnsureVisible(ByVal iIndex As Integer)

ParameterDescription
iIndexIndex of the item to be displayed

Remarks

The EnsureVisible method arranges the contents of a list in a way that ensures that the element specified by the iIndex parameter is visible. This parameter should be between 0 and ListCount -1. If the list does not contain enough elements for the scrolling arrows to appear, this method has no effect.

If the Redraw property is set to True, the list is redrawn immediately in order to reflect the new state of the control.

The example below adds a random element to the end of the list, and scrolls the elements if necessary to make it visible:

Private Sub Button1_Click()
  List1.AddItem Chr(Rnd()*26+Asc("A"))
  List1.EnsureVisible List1.NewIndex
End Sub

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A