Jump to content

GUICtrlCreateList and GUICtrlSetData


fspafford
 Share

Recommended Posts

I can't seem to add the same text more than once to a list control. For example, if I use:

GUICtrlSetData($mylist, "test")

GUICtrlSetData($mylist, "test")

then "test" appears once in the list.

Can this behavior be changed?

I am using a list control to log some information, and I want to allow "duplicates".

Thanks,

Frank

Frank

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUICtrlRead",250,120)

$n1  = GUICtrlCreateList("", 10, 10, -1, 100)
GUICtrlSetData(-1, "item1|item1|item1")

GUISetState ()

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

I can't seem to add the same text more than once to a list control. For example, if I use:

GUICtrlSetData($mylist, "test")

GUICtrlSetData($mylist, "test")

then "test" appears once in the list.

Can this behavior be changed?

I am using a list control to log some information, and I want to allow "duplicates".

Thanks,

Frank

Your example should work but there appears to a minor bug or undocumented behaviour

#include <GUIConstants.au3>

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered

$mylist1 = GUICtrlCreatelist ("", 10,10)
GUICtrlSetData($mylist1, "test")
GUICtrlSetData($mylist1, "test")
; only one entry appears in list

$mylist2 = GUICtrlCreatelist ("", 10,200)
GUICtrlSetData($mylist2, "test")
GUICtrlSetData($mylist2, "test|")
; two entries appear in list

GUISetState ()       ; will display an empty dialog box with a list control with focus on

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Edit: A bug report has been submitted

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

That example does work, but I want to use multiple calls to GUICtrlSetData so that the list is updated while the script is running. Can this be done?

#include <GUIConstants.au3>

GUICreate("My GUI",400,200)

$in1 = GUICtrlCreateInput ("put data here",220,10,150)
$in2 = GUICtrlCreateInput ("put data here",220,40,150)
$in3 = GUICtrlCreateInput ("put data here",220,70,150)
$mylist = GUICtrlCreatelist ("",10,10,200,200)
$go = GUICtrlCreateButton ("Set Data in List control", 220,110,150)

GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $one = GUICtrlRead ($in1)
    $two = GUICtrlRead ($in2)
    $three = GUICtrlRead ($in3)
    If $msg = $go Then
        GUICtrlSetData ($mylist , "")
        GUICtrlSetData ($mylist ,$three &"|"& $two &"|"& $one,$one)
    EndIf
Wend

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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