Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Scrolling a List Box automatically

I have a list box in an OI form that is constantly getting new rows of text that I want to be visible as it's getting added. Once it reaches the bottom it continues to get added however I'm not able to see the newly added text unless I scroll to the bottom when it's finished running. How would I go about automatically scrolling this list box to the last item that got added? In other words, I want it to work like a command prompt where it shows you the last values added up until the input line of the directory that we're in (in my case the last line should be the last value that got added).

So far, I've tried using the code : scrollTest = Send_Message(@window: ".LBX_PROGRESS", "SCROLL", 0, -10) and using Get and Set properties for the VPOSITION that as each new line gets added.

Thanks!

Comments

  • I could also use the "TOPPOS" event and increment the value once it reaches the bottom. However, this is still a problem because the way I'm adding these new rows of texts is by using a Get_Property to get the current list of text, append the new value to that list, and then use set property to set the new value which seems to be rewriting the top position. If there is an easier way to upload new rows of text to this window please let me know. The goal of the window is to show an active progress list of an automation tool I'm working on. Just looking to get it to scroll accordingly without any human intervention, almost like running the command prompt "ping -t" to get an ongoing list of replies where it shows us the newest value at the bottom.
  • Could you use an EditBox control instead? It might be easier to work with to show the data and position the scroll to the bottom of your list. I have found the OI LISTBOX control difficult to use.
  • I'll try that out instead, so far I managed to get it working if I increment the "TOPPOS" by one and set a delay however it isn't 100% the way I want it yet. Thank you!
  • Resetting the LIST property causes all items to be cleared and then re-added, which is why TOPPOS resets. It's far more efficient to use the INSERT method with an index of -1 to append a new item to the end of the list box. Then set TOPPOS to the size of your list after each insert.

    For i = 1 to 1000 Send_Message(@Window:".LISTBOX", "INSERT", -1, "Item ":i) Set_Property(@Window:".LISTBOX", "TOPPOS", i) Next i
  • Awesome I tried that out and worked out well, that SEND_MESSAGE function seems to be more efficient than the Set_Property function I was using too. Thank you!
Sign In or Register to comment.