WebListBox Scroll While Searching

I’ve got a weblistbox that I’m using a recursive search routine to find records. The routing works okay and the records are being found as expected. However, I find the visual scrolling of the weblistbox while the search is happening to be distracting. Is there a way to stop the weblistbox from scrolling and then simply displaying the found record automatically?

Thanks!

How are you performing this search? You can iterate through the listbox contents using the .Cell method without affecting the selected row or scrolling.

Jay,

Here’s the code (lifted and tweaked a bit from hither and yon):

dim strValue As String
Dim i As Integer
Dim j As Integer
dim FoundAt As Integer = -1

strValue = txtSearch.Text
FoundAt = -1

for i = 0 to lbDataList.RowCount-1
for j = 0 to lbDataList.ColumnCount-1
if InStr(lbDataList.Cell(i,j),strValue)>0 then
FoundAt = i
exit
end
next
next
if FoundAt >= 0 then
lbDataList.ListIndex = FoundAt
else
MsgBox “The text “+Chr(34)+strValue+Chr(34)+” could not be found.”
end

The scrolling motion occurs when the lbDataList.ListIndex is set to the FoundAt value. I’m trying to avoid the scrolling motion of the weblistbox when the listindex value is set.

Thanks!

Ah, I see. I thought you were somehow “moving” through the listbox as you searched. I have not used a listbox before with enough rows to notice this happening.

I don’t know of a way to directly jump to a certain row without it animating the scroll to get there (in Xojo). In fact, I don’t know enough HTML/js to know if it’s even possible outside of Xojo. Any js gurus know if it’s possible? If so, then a feature request to add it to Xojo would be in order.

for i = 0 to lbDataList.RowCount-1 for j = 0 to lbDataList.ColumnCount-1 if InStr(lbDataList.Cell(i,j),strValue)>0 then dim TextFound as string = lbDataList.Cell(i,j) FoundAt = i exit end next next if FoundAt >= 0 then // lbDataList.ListIndex = FoundAt MsgBox(TextFound) // You can then set the listIndex at a more convenient time else MsgBox "The text "+Chr(34)+strValue+Chr(34)+" could not be found." end