Jump to content

Unselect listbox


HighGuy
 Share

Recommended Posts

Gary/CyberSlug's GUIList.au3 UDF library offered in this thread should help you out with this.

Yes, I already had a look at GUIList.au3, but the function that would help me with my problem (_GUICtrlListSetSel) is unfortunately only valid for multi-selection list boxes B) .

The only solution I have at the moment is to refill the list with no default selection given to GUICtrlSetData().

Any other ideas?

Link to comment
Share on other sites

The thread linked above contains some discussion about a _GUICtrlListSelectIndex() function.

Use this message only with single-selection list boxes.

You cannot use it to set or remove a selection in a multiple-selection list box.

To me, this implies that you may be able to use it to remove a selection in a single-selection list box. I would suggest giving it a try with some non-existent index (like -1) and observing the result; Gary would most likely be happy to offer advice to you in that thread if he doesn't see this one.
Link to comment
Share on other sites

The thread linked above contains some discussion about a _GUICtrlListSelectIndex() function.

Indeed it works with _GUICtrlListSelectIndex($h_listbox, -1) :o . Thank you for the hint Alex and thank you Gary for this new function! B)

Maybe it would make sense to create a new funtion _GUICtrlListUnSelect($h_listbox) that uses this call.

Link to comment
Share on other sites

I'm getting the following error(s) when I include the Guilist from the beta.

C:\Program Files\AutoIt3\Include\guilist.au3(385,37) : ERROR: DllStructCreate(): undefined function.

Local $p = DllStructCreate ($RECT)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\guilist.au3(390,90) : ERROR: DllStructGetPtr(): undefined function.

Local $ret = GUICtrlSendMsg($h_listbox, $LB_GETITEMRECT, $i_index, DllStructGetPtr ($p)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\guilist.au3(392,26) : ERROR: DllStructDelete(): undefined function.

DllStructDelete ($p)

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\guilist.au3(395,58) : ERROR: DllStructGetData(): undefined function.

Local $array = StringSplit(DllStructGetData ($p, $left)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\WINNT\Profiles\scott_lawrence\Desktop\GUIWrapper.au3 - 4 error(s), 0 warning(s)

I'm not using any functions from it at the moment.

I've narrowed it down to guilist.au3, because I get the same error when it's just a blank au3 file with the only the include line.

Please advise.

Thanks.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

  • 6 months later...

The _GUICtrlListSetSel() method to unselect in the list box isn't working for me.

Here's an example:

#include <GUIConstants.au3>
#include <GuiList.au3>

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list"); will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("toggle", 10,150,75,25)
Dim $ADDRESS_LIST = GUICtrlCreateList('', 10, 10, 145, 105,BitOR($WS_BORDER,$WS_VSCROLL,$LBS_MULTIPLESEL,$LBS_DISABLENOSCROLL))
;~ GUICtrlSetLimit(-1,200); to limit horizontal scrolling
GUICtrlSetData(-1,'This|Doesnt|work|for|me')
;~ $close=GUICtrlCreateButton ("my closing button", 64,160,175,25)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    Select
        case $msg = $add
            _GUICtrlListSetSel($ADDRESS_LIST,0)
    EndSelect
Wend
Any ideas as to why? Edited by strate
INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

  • 6 years later...
  • 3 years later...

Tell me, please, how to reset the selection, if the property is used ListBox $LBS_EXTENDEDSEL

So many functions for working with ListBox, but there is no function deselect all selected items. :(

_GUICtrlListBox_SetCurSel($Listbox, -1)

This method unfortunately does not work with multiple choice.

Thanks.

Link to comment
Share on other sites

  • Moderators

AndreyS,

Get the list of selected items and deselect them individually:

#include <GUIConstantsEx.au3>

#include <GuiListBox.au3>

$sText = "A|B|C|D|E|F|G|H|I|J|K|L|M"

$hGUI = GUICreate("Test", 500, 500)

$cList = GUICtrlCreateList("", 10, 10, 300, 300, $LBS_EXTENDEDSEL)
GUICtrlSetData($cList, $sText)

$cUnSel = GUICtrlCreateButton("UnSel", 10, 450, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cUnSel

            $aSel = _GUICtrlListBox_GetSelItems($cList)
            For $i = 1 To $aSel[0]
                ConsoleWrite($aSel[$i] & @CRLF)
                _GUICtrlListBox_SetSel($cList, $aSel[$i], False)
            Next
    EndSwitch
WEnd

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

  • 1 month later...
On 12/14/2015 at 7:52 AM, Melba23 said:

AndreyS,

Get the list of selected items and deselect them individually:

#include <GUIConstantsEx.au3>

#include <GuiListBox.au3>

$sText = "A|B|C|D|E|F|G|H|I|J|K|L|M"

$hGUI = GUICreate("Test", 500, 500)

$cList = GUICtrlCreateList("", 10, 10, 300, 300, $LBS_EXTENDEDSEL)
GUICtrlSetData($cList, $sText)

$cUnSel = GUICtrlCreateButton("UnSel", 10, 450, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cUnSel

            $aSel = _GUICtrlListBox_GetSelItems($cList)
            For $i = 1 To $aSel[0]
                ConsoleWrite($aSel[$i] & @CRLF)
                _GUICtrlListBox_SetSel($cList, $aSel[$i], False)
            Next
    EndSwitch
WEnd

M23

Fantastic! Thanks Melba! I was stumped trying to do this.

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