Jump to content
Sign in to follow this  
Kornel

listbox

Recommended Posts

Kornel

Hi, I need to get all entrys of list box, which function I should use?

Share this post


Link to post
Share on other sites
water

_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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Scriptonize

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

Share this post


Link to post
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
Sign in to follow this  

×