By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Removing items from the "SelectedItems" in a ListBox

P: n/a
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!??
Nov 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Cor
Hi Robin,

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

Cor
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!??

Nov 20 '05 #2

P: n/a
"Robin Tucker" <id*************************@reallyidont.com> schrieb
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)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
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

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:bu*******************@news.demon.co.uk...
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!??

Nov 20 '05 #4

P: n/a
"Cor" <no*@non.com> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
True.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uD****************@tk2msftngp13.phx.gbl...
"Cor" <no*@non.com> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

P: n/a
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
Nov 20 '05 #7

P: n/a
Cor
> True.
I think this removes the item from the listbox, not only from the list of selected items.


I am glad you see it also CJ

:-))

Cor
Nov 20 '05 #8

P: n/a
"Cor" <no*@non.com> schrieb
mylistbox.setselected(index, true)


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

Nov 20 '05 #9

P: n/a
=)

"Cor" <no*@non.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
True.

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


I am glad you see it also CJ

:-))

Cor

Nov 20 '05 #10

P: n/a
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 ;)

"Cor" <no*@non.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
True.

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


I am glad you see it also CJ

:-))

Cor

Nov 20 '05 #11

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

=0
"Cor" <no*@non.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
True.

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


I am glad you see it also CJ

:-))

Cor

Nov 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.