Removing items from the "SelectedItems" in a ListBox

R

Robin Tucker

SelectedItems and SelectedIndices appear to be read-only, so I cannot remove
a selected item. I need to do this to synchronise the selection in my list
with the selection in other views (ie. select in another view and the
selected items in my list change).

How can I change the selected items in a list box!??
 
A

Armin Zingler

Robin Tucker said:
SelectedItems and SelectedIndices appear to be read-only, so I cannot
remove a selected item. I need to do this to synchronise the
selection in my list with the selection in other views (ie. select in
another view and the selected items in my list change).

How can I change the selected items in a list box!??

mylistbox.setselected(index, true)
 
C

CJ Taylor

Dim t As ListBox.SelectedObjectCollection

t = Me.lst_Classification.SelectedItems



Could you do something like this and do a t.Add / t.Remove whatever?



-CJ
 
A

Armin Zingler

Cor said:
Did you try the removeAT?
\\\\
listBox1.Items.RemoveAt(x)
///

I think this removes the item from the listbox, not only from the list of
selected items.
 
C

Cor

Hi Armin,
mylistbox.setselected(index, true)

I think this set the selected item

To remove (deselect) is
mylistbox.setselected(index, false)

:))))))

I give no other answer on your comment, you are right I think

:)

Cor
 
A

Armin Zingler

Cor said:
I think this set the selected item

To remove (deselect) is
mylistbox.setselected(index, false)

:))))))

Was an example only how to call which function. (I know you know...)
 
C

CJ Taylor

I would like to point out thought I did see it, but did not make a comment
on it until AFTER Armin had.

=0
 
R

Robin Tucker

Cheers all. As so often happens, I had a Doh! moment just after posting the
question. The method isn't on the item (of course) or the item collection,
its on the list itself, so I used ListBox.SetSelectedItem(a, b). Bad design
imho ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top