Jump to content



Photo

Listbox: Delete selected Item


  • Please log in to reply
4 replies to this topic

#1 Arctor

Arctor

    Wayfarer

  • Active Members
  • Pip
  • 65 posts

Posted 06 June 2004 - 06:14 PM

Hi all,
can anyone take a look at this? I can't get it to delete an Item from the list. :D

Plain Text         
FileChangeDir(@ScriptDir) GUICreate("zzz", 320, 260) $Listbox1 = GuiSetControl ("list", "", 10,20,300,200) $AddDir = GUISetControl ("button", "Add Dir", 10,210,100,20) GuiSetControlNotify() $DelItem = GUISetControl ("button", "Del Item", 110,210,100,20) GuiSetControlNotify() $ClearList = GUISetControl ("button", "Clear List", 210,210,100,20) GuiSetControlNotify() ;------------------------------------------------- While GUIMsg() > 0 if GuiRead () = $AddDir Then $dirpath = FileSelectFolder("Choose a directory.", "", 0)     If @error <> 1 AND $dirpath <> "" Then     GUISetControlData($Listbox1, $dirpath)     EndIf EndIf if GuiRead () = $DelItem Then $selitem = GuiRead($Listbox1) ;;;missing code to remove the selected item from the list EndIf if GuiRead () = $ClearList Then GUISetControlData($Listbox1, "") EndIf Wend


If I use "ControlCommand" with the command "DelString", I can only delete the first Item in the List.
Although the Documentation is one of the best I ever saw, I can't find it.
I already searched this Forum and also yahoo.group.
It would also be nice to know: Is it possible to change the value of an item in the list? But thats not the way important as to delete one.

arctor







#2 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 06 June 2004 - 06:17 PM

There are some ways.
One:
You can use GUISetControlData() for refresh with a StringReplace inside.

Edited by josbe, 06 June 2004 - 06:19 PM.


#3 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 06 June 2004 - 07:33 PM

If there are no duplicate entries, then you can ead the selected string with GuiRead(). Then use ControlCommand with "FindString" to get the occurence, then you can use that occurence with DelString. It's a long way about it, but it works.

#4 Arctor

Arctor

    Wayfarer

  • Active Members
  • Pip
  • 65 posts

Posted 06 June 2004 - 07:40 PM

There are some ways.
One:
You can use GUISetControlData() for refresh with a StringReplace inside.

Hi josbe,
thx for the quick answer.

Can't get the syntax for your suggestion.
But it brought me to another solution.
$selitem = GuiRead($Listbox1) $item2delete = ControlCommand ( "zzz", "", "ListBox1", "FindString", $selitem) ControlCommand ( "zzz", "", "ListBox1", "DelString", $item2delete)
This works for me. :D

You can use GUISetControlData() for refresh with a StringReplace inside.

Can you give an example for that? I'm aways looking for solutions, that fits in 1 line. ;-)

There are some ways.

Another one? hehe

arctor

#5 Arctor

Arctor

    Wayfarer

  • Active Members
  • Pip
  • 65 posts

Posted 06 June 2004 - 07:52 PM

If there are no duplicate entries, then you can ead the selected string with GuiRead(). ...

Hi Valik,
what you said is exactly what I just found.
I tested it with duplicate and like duplicate entries. It will delete only one of them

arctor




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users