Jump to content

Recommended Posts

Posted (edited)

I'm trying to use _GUICtrlListView_Create and _GUICtrlListView_GetSelectedIndices but that doesn't work. I have to use _GUICtrlListView_Create instead of GUICtrlCreateListView because I want to be able to edit the elements in place with other functions. Is there a way to delete multiple rows with with _GUICtrlListView_Create?

Edited by Champak
  • Moderators
Posted

Champak,

From the page in very useful Help file for _GUICtrlListView_Create: "Default Style: $LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS".

So you need to use BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS) as the style when you create the ListView, if you wish to make multiple selections.

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

 

Posted

_GUICtrlListView_SetItemSelected and ensure $LVS_SINGLESEL is not in the extended style of _GUICtrlListView_Create

I'm trying to use _GUICtrlListView_Create and _GUICtrlListView_GetSelectedIndices but that doesn't work. I have to use _GUICtrlListView_Create instead of GUICtrlCreateListView because I want to be able to edit the elements in place with other functions. Is there a way to select multiple rows with with _GUICtrlListView_Create?

Posted (edited)

To both of you, that's how I have it alreay:

$LISTVIEW = _GUICtrlListView_Create($GUI_LIST, "COL1|COL2", 5, 5, 590, 300, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
    _GUICtrlListView_SetExtendedListViewStyle($LISTVIEW, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_TRACKSELECT))

Thanks.

Edited by Champak
Posted

Could you post more relevant code on how you are selecting and where your multi select fails?

To both of you, that's how I have it alreay:

$LISTVIEW = _GUICtrlListView_Create($GUI_LIST, "COL1|COL2", 5, 5, 590, 300, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
    _GUICtrlListView_SetExtendedListViewStyle($LISTVIEW, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_TRACKSELECT))

Thanks.

  • Moderators
Posted

Champak,

If I put your creation code as posted in the example from the Help file (OK, I have to change the handles, but nothing else), I can get multiple selections without any problems.

You must be doing something elsewhere in your script. You are keeping the Ctrl key pressed, I suppose?

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

 

Posted (edited)

I'm sorry, it was last night I saw my problem and decided to post this morning and forgot exactly what it was. The actual problem is I can't use _GUICtrlListView_GetSelectedIndices() to delete the rows. Here is my script deleting the list and array elements. But it doesn't work unless I use the other listviewcreate.

$H_LISTVIEW = GUICtrlGetHandle($LISTVIEW);this is global

Func Click_33();Remove
    $UNIVERSALVAR1 = _GUICtrlListView_GetSelectedIndices($H_LISTVIEW , True)
    ;_ArrayDisplay($UNIVERSALVAR1)
    For $I = UBound($UNIVERSALVAR1) - 1 To 1 Step -1
        ;For $i = 2 To UBound($UNIVERSALVAR1) - 1
        ;_CONSOLEWRITE($UNIVERSALVAR1[$i])
        _ArrayDelete($POIARRAY, $UNIVERSALVAR1[$i]+2)
    Next
    _GUICtrlListView_DeleteItemsSelected($H_LISTVIEW)
EndFunc
Edited by Champak
Posted (edited)

I think figured a different way to attack this, to put this:

For $I = UBound($POIARRAY) - 1 To 1 Step -1
        If _GUICtrlListView_GetItemState($H_LISTVIEW, $i-2, $LVIS_SELECTED) = 2 Then
                _ArrayDelete($POIARRAY, $i)
                _GUICtrlListView_DeleteItem($H_LISTVIEW, $i-2)
        EndIf
    Next

I haven't tested it yet, but I think it should work.

EDIT: It does work, I just wish there is a "better" way to do this, because I think this will be slow with a large array/list

Edited by Champak

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
×
×
  • Create New...