deleting items from a listbox
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: deleting items from a listbox
one listbox with 6 items. highlight items 2, 4 & 6. click button and have items 2, 4 & 6 removed from the listbox. one click.
Re: deleting items from a listbox
Did you try the demo form I just posted? It does exactly that.boyddt_co wrote:one listbox with 6 items. highlight items 2, 4 & 6. click button and have items 2, 4 & 6 removed from the listbox. one click.
Re: deleting items from a listbox
Here is a more complete version that shows how to move items in both directions with clicks or with buttons. It can move one, ten or all items on a click.
- Attachments
-
- Demo-ListBoxCapabilities.pff
- (15.92 KiB) Downloaded 228 times
Re: deleting items from a listbox
This demo shows how to use relational list techniques with a listbox.
- Attachments
-
- Demo-ListBoxRelationalCascade.pff
- (7.63 KiB) Downloaded 217 times
Re: deleting items from a listbox
here is the code that does what I want. Thank you for your help.
$buttonClearSelectedSun_Click={
$selectedCount = $lb_sun.SelectedItems.Count
for($selectedCount;$selectedCount -ge 1; $selectedCount--)
{
$idx = $lb_sun.SelectedIndex
$lb_sun.Items.RemoveAt($idx)
}
}
$buttonClearSelectedSun_Click={
$selectedCount = $lb_sun.SelectedItems.Count
for($selectedCount;$selectedCount -ge 1; $selectedCount--)
{
$idx = $lb_sun.SelectedIndex
$lb_sun.Items.RemoveAt($idx)
}
}
Re: deleting items from a listbox
Sorry but that code will not work as you think it will. It is basically doing nothing in a loop.
You loop does many executions of the same item.
$idx=$lb_sun.SelectedIndex
$lb_sun.Items.RemoveAt($idx)
This should do what you want:
while($idx=$lb_sun.SelectedIndex){
$lb_sun.Items.RemoveAt($idx)
}
In your is index is null you will blow up.
You loop does many executions of the same item.
$idx=$lb_sun.SelectedIndex
$lb_sun.Items.RemoveAt($idx)
This should do what you want:
while($idx=$lb_sun.SelectedIndex){
$lb_sun.Items.RemoveAt($idx)
}
In your is index is null you will blow up.