Jump to content

GUICtrlCreateList Example


taylansan
 Share

Go to solution Solved by TheXman,

Recommended Posts

Hello, 

In the GUICtrlCreateList default example, whenever I click the Add button I can see "You clicked button No1" is added into the list. But the list is always kept on the top (red arrows). I want to go the end of the list whenever I click the Add button (green arrows). 

image.thumb.png.6470ad0c86d58522c2ecd20e85e04f43.png

 

This is the original example of GUICtrlCreateList (except the two commented lines which I added them). I know I need to add something after Case $idButton_Add:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sMESSAGE = "The following buttons have been clicked"

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $sMESSAGE)
    Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton_Add
                GUICtrlSetData($idMylist, "You clicked button No1|")
                ;I think I need to add something here, to make the list jump to the last item
                ;GUICtrlSetState($idMylist, "go to the last item")
            Case $idButton_Clear
                GUICtrlSetData($idMylist, "")
            Case $idButton_Close
                MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

I looked for the GUICtrlSetState function, but I couldn't find which parameter I should use to go to the last item in the list. 

I don't want to force send keys such as Send("{END}") which will of course go the last element.

How can I go to the last item in the list? Is GUICtrlSetState function with a special parameter or a different function? 

 

TY.

Link to comment
Share on other sites

  • Solution
3 hours ago, taylansan said:

I want to go the end of the list whenever I click the Add button (green arrows).

How can I go to the last item in the list?

You can use _GUICtrlListBox_SetCurSel() to set the current selection to the last entry in the listbox and scroll it into view.

#include <GuiListBox.au3>
.
.
.
Case $idButton_Add
    GUICtrlSetData($idMylist, "You clicked button No1|")
    _GUICtrlListBox_SetCurSel($idMylist, _GUICtrlListBox_GetCount($idMylist) - 1)

 

Edited by TheXman
Link to comment
Share on other sites

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...