Sign in to follow this  
Followers 0
Xink

GuiCtrlCreateList multiple selection with Ctrl key?

9 posts in this topic

Hello,

Is it possible to enable the control key to select multiple entries in de GUICtrlCreateList?

I have noticed the control key is working with GUICtrlCreateListView.

Any help are appreciated

Xink

Share this post


Link to post
Share on other sites



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

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button, $i

GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1)
$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            $ret = _GUICtrlListGetSelItems ($listbox)
            If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems")
            Else
                For $i = 1 To $ret[0]
                    MsgBox(0, "Selected", $ret[$i])
                Next
            EndIf
    EndSelect
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you for your reply.

Sorry i am not clear at the first time.

I want to select multiple items with the Ctrl key and not with the mouse.

The mouse can select only one item.

Is this possible?

Share this post


Link to post
Share on other sites

The only way to select items is with the mouse. You hold control and click more than one item. As long as the $LBS_MULTIPLESEL is used, you can click more than one, as long as you hold control.

Share this post


Link to post
Share on other sites

The only way to select items is with the mouse. You hold control and click more than one item. As long as the $LBS_MULTIPLESEL is used, you can click more than one, as long as you hold control.

If you not hold down the Ctrl key, you still can select multiple items with the mouse.

I only want to selected multiple items with the Ctrl key, if Ctrl key is not hold down, only 1 item can selected.

See GUICtrlCreateListView, this is exactly what i want, but now in GUICtrlCreateList.

Share this post


Link to post
Share on other sites

Use $LBS_EXTENDEDSEL (0x800)


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Use $LBS_EXTENDEDSEL (0x800)

How do i use $LBS_EXTENDEDSEL? i cannot found this in the help file.

When i try this, it is not recognized. Variable used without being declared.

GUICtrlCreateList("", 424, 359, 339, 201, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER))

Share this post


Link to post
Share on other sites

When i try this, it is not recognized. Variable used without being declared.

So declare it.

Global Const $LBS_EXTENDEDSEL = 0x800
...
...
GUICtrlCreateList("", 424, 359, 339, 201, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER))

Or don't declare, just plug it's value into GUICtrlCreateList() directly, if you don't care about readability of your code...

GUICtrlCreateList("", 424, 359, 339, 201, BitOR($LBS_SORT,$LBS_STANDARD,0x800,$WS_VSCROLL,$WS_BORDER))

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Thank you very much, it works :)

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  
Followers 0