Jump to content

Auto Scrolling in Listbox


scriptcoder
 Share

Recommended Posts

Hi all!

I've added a ListBox to my GUI as a way to update the user as to what steps the application has already taken. I want to add a new "line" to the listbox everytime something significant happens.

The problem I am having is that with too many "lines" the listbox does not scroll automatically to keep up with the lines but instead stays focused on the first set of "lines" Does anyone know how to make the listbox scroll automatically when the listbox is filled with lines?

Sorry about my english I'm still learning.... :)

Link to comment
Share on other sites

Hi all!

I've added a ListBox to my GUI as a way to update the user as to what steps the application has already taken. I want to add a new "line" to the listbox everytime something significant happens.

The problem I am having is that with too many "lines" the listbox does not scroll automatically to keep up with the lines but instead stays focused on the first set of "lines" Does anyone know how to make the listbox scroll automatically when the listbox is filled with lines?

Sorry about my english I'm still learning.... :)

You need _GUICtrlListBox_GetCount() to get the number of lines from ListBox and _GUICtrlListBox_SetSel() to select the last item from list.

When the words fail... music speaks.

Link to comment
Share on other sites

Thank you for a quick reply Andreik.

I cannot get it to work. I have the following to detect and change the listbox items.:

CODE
$numberofitems = _GUICtrlListBox_GetCount($List1)

_GUICtrlListBox_SetSel($List1,$numberofitems)

I feel like I'm missing something simple. Could you (or someone else) provide an example? :)

Link to comment
Share on other sites

scriptcoder

Example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>

$hGUI = GUICreate("Test", 300, 200)

$ListBox = GUICtrlCreateList("", 10, 10, 280, 180)
GUICtrlSetData($ListBox, _
                "New string|New string|New string|New string|New string|New string|New string|New string|New string")

GUISetState()

AdlibEnable("_StringAdd", 1000)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

AdlibDisable()

Func _StringAdd()
    GUICtrlSetData($ListBox, "New string|")
    
    GUICtrlSendMsg($ListBox, $WM_VSCROLL, $SB_LINEDOWN, 0) ;Scroll the ListBox control
EndFunc   ;==>_StringAdd

:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...