TopIndex: Integer;
The TopIndex property determines index of the first visible string in the component.
String indexing starts with zero. On changing the property value, the string list will be scrolled to make the string with the TopIndex index the first visible in the component area. If index of one of the last strings or index that is greater that the number of existing strings, the scrolling is made to the end of string list in the component.
Executing the example requires a form with the ListBox component named ListBox1 on it and the IntegerEdit component named IntegerEdit1. The OnChange event handler is added for IntegerEdit1. See below the full form code.
Class TESTForm: Form
ListBox1: ListBox;
IntegerEdit1: IntegerEdit;
Sub IntegerEdit1OnChange(Sender: Object; Args: IEventArgs);
Begin
ListBox1.TopIndex := IntegerEdit1.Value;
End Sub IntegerEdit1OnChange;
End Class TESTForm;
If the value is changed, the ListBox1 component is scrolled in the IntegerEdit1 in order the first visible string becomes the string, which index is equal to the IntegerEdit1 value.
See also: