Jump to content

Multiple selection ListBox read


EndFunc
 Share

Recommended Posts

I've been trying to read a list that uses the $LBS_EXTENDEDSEL. When I do a GuiCtrlRead, it only returns the last value selected. What am I missing? How do I return all the values selected in the ListBox?

Thanks

helpfile

$Input_Site3_Folder = GUICtrlCreateCombo($exp, 40, 160, 405)

GUICtrlSetData(-1, $exp0 & "|" & $exp1 & "|" & $exp2)

GUICtrlSetState(-1, 256)

Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

  • Moderators

EndFunc,

I had the same problem a while ago - took ages for the penny to drop! Try holding down the Ctrl key while you select and then use _GUICtrlListBox_GetSelItems .

M23

Edited because I just realised you were only using GUICtrlRead. Sorry.

And again because PsaltyDS beat me to it!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I've been trying to read a list that uses the $LBS_EXTENDEDSEL. When I do a GuiCtrlRead, it only returns the last value selected. What am I missing? How do I return all the values selected in the ListBox?

Thanks

Use _GUICtrlListBox_GetSelItems() :)

helpfile

$Input_Site3_Folder = GUICtrlCreateCombo($exp, 40, 160, 405)

GUICtrlSetData(-1, $exp0 & "|" & $exp1 & "|" & $exp2)

GUICtrlSetState(-1, 256)

That only sets $GUI_FOCUS on the control... how does that help? :)
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You both misunderstood, I already know how to create a list box so I don't need to use the help file for that.

thanks, I already know how to do multiple selections, that is a basic windows function.

What I was referring to is I am trying to read the control with GuiCtrlRead while I have all multiple selections but it only retrieves the last selected item.

I am using an Array to read from an Ini file to populate my listbox which works fine.

I can't figure out how to show all the items I have selected using GuiCtrlRead. Output can be a message box , log etc. Doesn't matter about output right now.

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Ok I was able to use _GUICtrlListBox_GetSelItemsText

The problem I'm having now is that I can't get the array to reset. If I run it in a while loop and I run the Case again, it will add to the array with the same values.

How do I reset it? I tried re delcaring but that didn't work right or i wasn't doing it right.

This is the code I am running.

Local $ShowItems, $aShowItems, $List1
 $ShowItems = _GUICtrlListBox_GetSelItemsText($List1)
For $iI = 1 To $ShowItems[0]
        $aShowItems &= @LF & $ShowItems[$iI]
    Next
    MsgBox(0,0, $aShowItems)
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

  • Moderators

EndFunc,

I believe you are looking for _GUICtrlListBox_SetSel - from the Help file: An $iIndex of -1 means to toggle select/unselect of all items (ignores the $fSelect).

Although given my previous success rate with this thread, you may wish to ignore this. ;-0

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok I was able to use _GUICtrlListBox_GetSelItemsText

The problem I'm having now is that I can't get the array to reset. If I run it in a while loop and I run the Case again, it will add to the array with the same values.

How do I reset it? I tried re delcaring but that didn't work right or i wasn't doing it right.

This is the code I am running.

Local $ShowItems, $aShowItems, $List1
 $ShowItems = _GUICtrlListBox_GetSelItemsText($List1)
For $iI = 1 To $ShowItems[0]
        $aShowItems &= @LF & $ShowItems[$iI]
Next
MsgBox(0,0, $aShowItems)
The array $ShowItems will be replaced with the new selection list, but the string $aShowItems will only get reset if you add a line of code to do it. Something like:
$aShowItems = ""

Your description and variable naming are confusing the issue. The leading lower case 'a' in a variable name indicates an array by convention, but you are naming a string variable using $aShowItems vice $sShowItems. The actual array has no indication of its type in $ShowItems. To fit with conventions and avoid confusion, I would have done something more like:

Local $sShowItems = "", $aShowItems, $List1
 $aShowItems = _GUICtrlListBox_GetSelItemsText($List1)
For $i = 1 To $aShowItems[0]
        $sShowItems &= @LF & $aShowItems[$i]
Next
MsgBox(0,0, $sShowItems)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The array $ShowItems will be replaced with the new selection list, but the string $aShowItems will only get reset if you add a line of code to do it. Something like:

$aShowItems = ""

Your description and variable naming are confusing the issue. The leading lower case 'a' in a variable name indicates an array by convention, but you are naming a string variable using $aShowItems vice $sShowItems. The actual array has no indication of its type in $ShowItems. To fit with conventions and avoid confusion, I would have done something more like:

Local $sShowItems = "", $aShowItems, $List1
 $aShowItems = _GUICtrlListBox_GetSelItemsText($List1)
For $i = 1 To $aShowItems[0]
        $sShowItems &= @LF & $aShowItems[$i]
Next
MsgBox(0,0, $sShowItems)

:)

You are right about that naming. Sorry didn't mean to confuse. I've made my adjustments.
EndFuncAutoIt is the shiznit. I love it.
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...