Sign in to follow this  
Followers 0
Datus

Remove selected GUICtrlCreateList item

3 posts in this topic

Spent few days on this, search forums, sample code, built in help etc, I can find lots for array lists but nothing for a simple GUICtrlCreateList

All i seem to be able to do is add or clear the lot, can anyone confirm this is all I can do or is there a simple way.

This is a rough bit of code as I work out how to do a feature before adding it to my own code. This is one of the last bits I need.

Could be I need to add "|" or something.

Anyway please help

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 625, 445, 193, 125)
$mylist=GUICtrlCreateList ("", 176,132,121,97)


$Last_loc =@WorkingDir
$browse_btn = GUICtrlCreateButton("Add folder", 380, 50, 100, 20)
$remove_btn = GUICtrlCreateButton("Remove folder", 380, 100, 100, 20)
$reset_btn = GUICtrlCreateButton("Remove all", 380, 150, 100, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select

        Case $msg = $GUI_EVENT_CLOSE 
            Exit

        Case $msg = $browse_btn

            $find_loc = FileSelectFolder("Choose a Folder.","",1,$Last_loc);brows for a folder to add
            If $find_loc = "" Then ContinueLoop 
            GUICtrlSetData($mylist,$find_loc);Adds selected folder.

    Case $msg = $remove_btn
         $z = GUICtrlRead($mylist)
         MsgBox(0,"",$z)
    ;what to type here to remove item from list
    
                cCse $msg =$Reset_btn   ;Clears all items
         GUICtrlSetData($mylist,"")
    EndSelect
wend

We live as we dream alone!

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Thanks GaryFrost :) , been racking my brains over it.

I did look at those commands and examples in help but for some reason wasnt very clear to me. Mind block on my part.

Thanks for help as its allowed me to prgress further on my own version of media centre.

ok for people who want to see finished example that works

#include <GUIConstants.au3>
#include <GUIListBox.au3>
$Form1 = GUICreate("Form1", 625, 445, 193, 125)
$mylist=GUICtrlCreateList ("", 176,132,121,97)


$Last_loc =@WorkingDir
$browse_btn = GUICtrlCreateButton("Add folder", 380, 50, 100, 20)
$remove_btn = GUICtrlCreateButton("Remove folder", 380, 100, 100, 20)
$reset_btn = GUICtrlCreateButton("Remove all", 380, 150, 100, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
        Case $msg = $browse_btn

            $find_loc = FileSelectFolder("Choose a Folder.","",1,$Last_loc)
            If $find_loc = "" Then ContinueLoop
            GUICtrlSetData($mylist,$find_loc)

        Case $msg = $remove_btn
        $z = _GUICtrlListBox_GetCurSel ($mylist)
            _GUICtrlListBox_DeleteString ($mylist, $z)

;what to type here to remove item from list
     case $msg =$Reset_btn
         GUICtrlSetData($mylist,"")
    EndSelect
wend
Edited by Datus

We live as we dream alone!

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