Web Listbox - how to make it scroll to a certain row?

Hello all,

I use a search box to locate a matching row in a Web listbox. I can find it, highlight it, but cannot get it to scroll so that it is showing (like at the top of the listbox).

For i As Integer = 0 to lstAccounts.RowCount -1
   If lstAccounts.CellTextAt(i, 0).IntegerValue = SID Then  // TextValue = trim(Me.text) Then
    Row = i
    Exit For
  End If
Next i

lstAccounts.SelectedRowIndex = Row
lstAccounts.SelectedRowColor = Color.Blue
lstAccounts.ScrollTo(Row)

What is the correct method to accomplish this?

Thanks,
Tim

Can you provide a sample app?

A simple app without highlight works:
scrollto

Is my code correct to make it move? Or am I missing something?

The code presented, other than filling the listbox, is all that I have at the moment, but it is part of a much bigger project.

Tim

Used the code you posted here, and this is the result:
toscrollv2

macOS, Chrome, Xojo 2023r2 (Firefox, Safari working too)


This is the code used for button ‘To 176’

// Listbox1.ScrollTo(175)
Var row As Integer
For i As Integer = 0 To listbox1.RowCount -1
  If listbox1.CellTextAt(i, 0).IntegerValue = 176 Then  // TextValue = trim(Me.text) Then
    Row = i
    Exit For
  End If
Next i

listbox1.SelectedRowIndex = Row
listbox1.SelectedRowColor = Color.Blue
listbox1.ScrollTo(Row)

Hmmm…

It does appear to work as you have shown…
Thanks,

Tim

I found the cause. Since 2023R2 is running so slow, I used 2023R1.1. It looks like there were some definite improvements made to the web listbox in the 2023R2 release.

Tim

1 Like