Sign in to follow this  
Followers 0
kor

How to create a gui item of list view with dynamic content?

25 posts in this topic

I am attempting to have my GUI look functionally similar to my attached screenshot.

post-48155-0-81917000-1300896192_thumb.j

I need to create a list view (I think this GUI type is a list view) that will populate based on an AD query of groups matching a specific critiera. The AD Get groups functions I'm sure I can figure out. The question I have is how to populate the tree view based on the output of the AD query since the number and names of the groups will always be dynamic.

I also need the ability to select multiple groups as seen in the screen shot. then when I click ok or add or whatever I call the button, it will take my selections and store them in an array.

Can anyone tell me what kind of gui items im going to need to get started?

Share this post


Link to post
Share on other sites



kor,

You are correct - it is a ListView control. :)

how to populate the tree view [...] since the number [...] will always be dynamic

Use a For...Next loop and create a row (or Item as it is called) for each entry. :)

the ability to select multiple groups

Do not include the $LVS_SINGLESEL style. :P

take my selections and store them in an array

Take a look at _GUICtrlListView_GetSelectedIndices and _GUICtrlListView_GetItemText in the Help file. :D

Anything else? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $hListView

_Main()

Func _Main()

    Local $GUI, $hImage
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Name (RDN)", 300)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "testing a long group description", 0)
    _GUICtrlListView_AddItem($hListView, "another test group", 0)
    _GUICtrlListView_AddItem($hListView, "a big long name of a test group", 0)
    _GUICtrlListView_AddItem($hListView, "another test group of similar name", 0)
    _GUICtrlListView_AddItem($hListView, "short group name", 0)
    _GUICtrlListView_AddItem($hListView, "even shorter", 0)
    
    guictrlcreatebutton("add", 200, 275, 80, 20)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Having trouble figuring out the multiple selection thing. I see the style in the helpfile, but I dont know how NOT to include it since it seems its included by default.

I'll play with the loop of dynamic content last. First I want to get the gui sorted, then I can figure out how to fill it :)

Share this post


Link to post
Share on other sites

You have to create the listview with the native AutoIt GUICtrlCreateListView command and set the styles manually, you can't include $GUI_SS_DEFAULT_LISTVIEW because the default style includes the SingleSel style. Just set the styles you want for the listview and don't include the styles you don't want and it should work ok.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

kor,

Having trouble figuring out the multiple selection thing. I see the style in the helpfile, but I dont know how NOT to include it since it seems its included by default.

Might I suggest the Setting Styles tutorial in the Wiki - I wrote it to explain exactly how to get over this problem. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

kor,

You should be using the $LVS_REPORT style to get the kind of ListView you are looking for, not $LVS_LIST. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Code so far. I am using a test array until I can work out the AD get objects function. I am having a problem though in how do I read multiple selections?

When I click on the value button it only gives me the first item I've selected instead of all of them.

I'm also wondering if this listview adds the | at the end of each selection item by default? IE (item1|) (item2|)

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Dim $array[4]

$array[0] = "name1"
$array[1] = "name2"
$array[2] = "name3"
$array[3] = "name4"

Example()

Func Example()
    Local $listview, $button, $msg
    
    GUICreate("listview items", 220, 250)

    $listview = GUICtrlCreateListView("test column                  ", 10, 10, 200, 150, $LVS_REPORT)
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    
    For $i = 0 To UBound($array) - 1
        GUICtrlCreateListViewItem($array[$i], $listview)
    Next

    GUISetState()

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $button
                MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)))
            Case $msg = $listview
                MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites

kor,

Do you actually read the replies you get? :)

I suggested _GUICtrlListView_GetSelectedIndices and _GUICtrlListView_GetItemText, yet here you are trying to use GUICtrlRead. :P

Furthermore you started off using the UDF-created ListView, which is advisable if you want to use the UDF functions and now you have switched to the native-created version. Any particular reason? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I have read the replies. The UDF way of doing things was harder for me to understand. But I've reworked my old example to get to the same spot I am at from the other code.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $hListView

Dim $array[4]

$array[0] = "name1"
$array[1] = "name2"
$array[2] = "name3"
$array[3] = "name4"

_Main()

Func _Main()

    Local $GUI, $hImage
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SORTASCENDING, $LVS_NOSORTHEADER))
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Name (RDN)", 300)

    ; Add items
    
    For $i = 0 To UBound($array) - 1
        _GUICtrlListView_AddItem($hListView, $array[$i])
    Next
    
    $button = guictrlcreatebutton("add", 200, 275, 80, 20)

    ; Loop until user exits
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $button
                                $1 = _GUICtrlListView_GetSelectedIndices($hListView, True)
                _ArrayDisplay($1)
            Case $msg = $hListView
                MsgBox(0, "listview", "clicked=" & GUICtrlGetState($hListView), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>_Main

I still don't know how to read multiple selections. I've looked at the getindicies, but it returns a number.

Edited by kor

Share this post


Link to post
Share on other sites

kor,

I've looked at the getindicies, but it returns a number

It actually returns an array of the indices selected, which your code displays. :)

So, as I also suggested, you use a For...Next loop with _GUICtrlListView_GetItemText to go the next step:

Case $msg = $button
    $1 = _GUICtrlListView_GetSelectedIndices($hListView, True)
    For $i = 1 To $1[0]
        ConsoleWrite(_GUICtrlListView_GetItemText($hListView, $1[$i]) & @CRLF)
    Next

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Is clear now. Thank you. I figured it would take another loop to read the selections.

EDIT: How would your code look if you were using the array call _GUICtrlListView_GetItemTextArray??

Having the selections in an array will make them much easier to deal with later down the road.

Edited by kor

Share this post


Link to post
Share on other sites

kor,

How would your code look if you were using the array call _GUICtrlListView_GetItemTextArray??

Have you tried? :)

The array you get is an array of thetext in the item and all sub-items in the same row - so it would not help you much.

:)

You will have to create an array and then put the returns from _GUICtrlListView_GetItemText into the elements. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Final step is injecting the 2 loops into each other.

Please see code. Also, if anyone can tell me how I might go about getting rid of group names using StringRegExp or something similar instead of having to name each group individually that would be great.

Code to give me an array of all groups in AD

#include <ad.au3>
#include <array.au3>

_AD_Open()

Global $list[10]

$list[0] = "Account Operators"
$list[1] = "Administrators"
$list[2] = "Backup Operators"
$list[3] = "Allowed RODC Password Replication Group"
$list[4] = "Cert Publishers"
$list[5] = "Certificate Service DCOM Access"
$list[6] = "Cryptographic Operators"
$list[7] = "Delegated Setup"
$list[8] = "Denied RODC Password Replication Group"
$list[9] = "DHCP Users"

$var = _AD_GetObjectsInOU("", "(objectcategory=group)", 2)

For $i = Ubound($var) - 1 to 0 Step - 1
    For $n = 0 to UBound($list) -1
        If StringInStr($var[$i], $list[$n]) then
            _ArrayDelete($var, $i)
        EndIf
    Next
Next

_AD_Close()

Code to create list gui

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $hListView

Dim $array[4]

$array[0] = "name1"
$array[1] = "name2"
$array[2] = "name3"
$array[3] = "name4"

_Main()

Func _Main()
    Local $GUI, $hImage
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)
    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SORTASCENDING, $LVS_NOSORTHEADER))
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Name (RDN)", 300)

    ; Add items
    For $i = 0 To UBound($array) - 1
        _GUICtrlListView_AddItem($hListView, $array[$i])
    Next
    
    $button = guictrlcreatebutton("add", 200, 275, 80, 20)

    ; Loop until user exits
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $button
                $1 = _GUICtrlListView_GetSelectedIndices($hListView, True)
                    For $i = 1 To $1[0]
                    ConsoleWrite(_GUICtrlListView_GetItemText($hListView, $1[$i]) & @CRLF)
            Next
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>_Main

I need to somehow combine the array output of all the groups, into the loop that creates each list item.

Share this post


Link to post
Share on other sites

kor,

Please post an example of the return you get from your _AD_GetObjectsInOU call (sanitised if necessary) and I will take a look. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Put the 2 scripts together with the second script after the first one, making sure that all of your global declarations, and ALL of your #include statements are at the start of the script. Second just change the lines here:

; Add items
    For $i = 0 To UBound($array) - 1
        _GUICtrlListView_AddItem($hListView, $array[$i])
    Next

To this:

; Add items
    For $i = 0 To UBound($var) - 1
        _GUICtrlListView_AddItem($hListView, $var[$i])
    Next

And that should populate the ListView


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

using code

#include <ad.au3>
#include <array.au3>

_AD_Open()

Global $list[50]

$list[0] = "Account Operators"
$list[1] = "Administrators"
$list[2] = "Backup Operators"
$list[3] = "$F51000-LP7DJ67UIARD"
$list[4] = "Allowed RODC Password Replication Group"
$list[5] = "Cert Publishers"
$list[6] = "Certificate Service DCOM Access"
$list[7] = "Cryptographic Operators"
$list[8] = "Delegated Setup"
$list[9] = "Denied RODC Password Replication Group"
$list[10] = "DHCP Users"
$list[11] = "Discovery Management"
$list[12] = "Distributed COM Users"
$list[13] = "DnsAdmins"
$list[14] = "DnsUpdateProxy"
$list[15] = "Domain Admins"
$list[16] = "Domain Computers"
$list[17] = "Domain Controllers"
$list[18] = "Domain Guests"
$list[19] = "Domain Users"
$list[20] = "Enterprise Admins"
$list[21] = "Enterprise Read-only Domain Controllers"
$list[22] = "Event Log Readers"
$list[23] = "Exchange All Hosted Organizations"
$list[24] = "Exchange Servers"
$list[25] = "Exchange Trusted Subsystem"
$list[26] = "Exchange Windows Permissions"
$list[27] = "ExchangeLegacyInterop"
$list[28] = "Guests"
$list[29] = "Help Desk"
$list[30] = "Hygiene Management"
$list[31] = "IIS_IUSRS"
$list[32] = "Incoming Forest Trust Builders"
$list[33] = "Network Configuration Operators"
$list[34] = "Performance Log Users"
$list[35] = "Performance Monitor Users"
$list[36] = "Pre-Windows 2000 Compatible Access"
$list[37] = "Public Folder Management"
$list[38] = "RAS and IAS Servers"
$list[39] = "Read-only Domain Controllers"
$list[40] = "Recipient Management"
$list[41] = "Records Management"
$list[42] = "Replicator"
$list[43] = "Schema Admins"
$list[44] = "Server Management"
$list[45] = "Server Operators"
$list[46] = "Storage Servers"
$list[47] = "Terminal Server License Servers"
$list[48] = "UM Management"
$list[49] = "Users"

$var = _AD_GetObjectsInOU("", "(objectcategory=group)", 2)

_ArrayDisplay($var)

For $i = Ubound($var) - 1 to 0 Step - 1
    For $n = 0 to UBound($list) -1
        If StringInStr($var[$i], $list[$n]) then
            _ArrayDelete($var, $i)
        EndIf
    Next
Next

_ArrayDisplay($var)

_AD_Close()

Result:

post-48155-0-16722300-1300999053_thumb.j

post-48155-0-40238200-1300999058_thumb.j

Please note this is a screen shot taken from after the array delete loop is run. I notice that even though row 0 says there are 172 rows, after the delete there are only 89 rows (as you can see in the example). I doubt this makes any difference, but just throwing it out there.

Share this post


Link to post
Share on other sites

Put the 2 scripts together with the second script after the first one, making sure that all of your global declarations, and ALL of your #include statements are at the start of the script. Second just change the lines here:

; Add items
    For $i = 0 To UBound($array) - 1
        _GUICtrlListView_AddItem($hListView, $array[$i])
    Next

To this:

; Add items
    For $i = 0 To UBound($var) - 1
        _GUICtrlListView_AddItem($hListView, $var[$i])
    Next

And that should populate the ListView

That worked! I had to change $i = 1 to remove the first row of the count of the groups, but yeah. thanks!

Share this post


Link to post
Share on other sites

kor,

Have you tried? :)

The array you get is an array of thetext in the item and all sub-items in the same row - so it would not help you much.

:)

You will have to create an array and then put the returns from _GUICtrlListView_GetItemText into the elements. :P

M23

Trying this, but not working

; Loop until user exits
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $button
                $1 = _GUICtrlListView_GetSelectedIndices($hListView, True)
                    For $i = 1 To $1[0]
                        ;$groups = _GUICtrlListView_GetItemText($hListView, $1[$i]) & @CRLF
                        $groups = _GUICtrlListView_GetItemTextArray($hListView)
                    Next
                _ArrayDisplay($groups)
            EndSelect
    Until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

kor,

Of course it does not work, I told you it would not! :)

But this might: :)

; Loop until user exits
Do
    $msg = GUIGetMsg()
    Select
        Case $msg = $button
            Local $groups[$i[0] + 1] ; create an array
            $1 = _GUICtrlListView_GetSelectedIndices($hListView, True)
            For $i = 1 To $1[0]
                $groups[$i] = _GUICtrlListView_GetItemText($hListView, $1[$i]) ; load the elements of the array with the text of the items selected
            Next
            _ArrayDisplay($groups) ; And display them
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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