Jump to content
Sign in to follow this  

Clearing Listbox Contents

Recommended Posts


Hi, is there a quick way to clear the contents of a listbox so that when you send new data to it, it is not just appended at the end. I tried both sending a null ("") value and pipe "|" as the help file said but that did not work :D . I see that ControlCommand can delete individual values but you'll have to know the number of occurences for it to work. :huh2:

Many thanks.

Share this post

Link to post
Share on other sites

Try GUISetControlData($lstItems, "") where $lstItems is the listbox control. This code works on machine.

Hope this helps!


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

$cmdClear= GUISetControl("button", "Clear", 64,32,75,25)
$lstItems= GUISetControl("list", "", 176,32,121,97)
GuiSetControlData($lstItems,"Line 1 |Line 2|Line 3")

$cmdClose = GUISetControl("button", "Close", 64,160,175,20)

While GUIMsg() > 0; will display a dialog box with 2 buttons
  $t = GUIRead()
    Case $t = $cmdClear
      GUISetControlData($lstItems, "")
    Case $t = $cmdClose
      MsgBox(0,"", "the closing button has been clicked")

Share this post

Link to post
Share on other sites

MX, that's strange, I tried that in my home pc and it didn't work. But now that I try it at work, it does work. :huh2:

Might be my mistake (most probable) :D . I guess I'll need to go over the code a few more times.

Thanks very much.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.