Jump to content

listbox


 Share

Recommended Posts

_GUICtrlListView_GetItemCount to get the number of entries and then loop through with _GUICtrlListView_GetItemText.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I've modded an example from the helpfile slightly:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $myListIDX

$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $sItems, $aItems, $hListBox

    ; Create GUI
    GUICreate("List Box Get Sel Items Text", 400, 296)
    $hListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState()

    ; Add strings
    _GUICtrlListBox_BeginUpdate($hListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Select all items.....
    $myListIDX = 0
    For $myListIDX = 0 to _GUICtrlListBox_GetCount($hListBox)
        _GUICtrlListBox_SetSel($hListBox, $myListIDX)
        If @error Then
            ConsoleWriteError(@error & @CRLF)
            ExitLoop
        EndIf
    Next

    ; Get indexes of selected items
    $aItems = _GUICtrlListBox_GetSelItemsText($hListBox)
    For $iI = 1 To $aItems[0]
        $sItems &= @LF & $aItems[$iI]
    Next
    MsgBox(4160, "Information", "Items Selected: " & $sItems)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

[[EDIT:]]You can also use

_GUICtrlListBox_SelItemRange
to select all items in the listbox Edited by Scriptonize

If you learn from It, it's not a mistake

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