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

How to select multiple items in ListBox control

P: n/a
ted
Hi,

I can't figure out how to set multiple items in a ListBox to selected when
the listbox is in a User Control.

When the ListBox is set in directly into a form I can use the following:
listbox.SelectionMode = SelectionMode.MultiExtended;
listbox.SelectedIndex = 1;
listbox.SelectedIndex = 2;

But when I set the ListBox into a User Control, this doesn't work. I can
only set one item to selected.

Any help appreciated. TIA.

-Ted

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try this:
listBox.SetSelected(0, true);
ted wrote:
Hi,

I can't figure out how to set multiple items in a ListBox to selected when
the listbox is in a User Control.

When the ListBox is set in directly into a form I can use the following:
listbox.SelectionMode = SelectionMode.MultiExtended;
listbox.SelectedIndex = 1;
listbox.SelectedIndex = 2;

But when I set the ListBox into a User Control, this doesn't work. I can
only set one item to selected.

Any help appreciated. TIA.

-Ted

--
Vit Zayko
Nov 17 '05 #2

P: n/a
Hi,

The weird thing is that it does work at all. I was under the impression
that the only way to select more than one item was using SetSelected method.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"ted" <te*********************@sbcglobal.net> wrote in message
news:XO****************@newssvr21.news.prodigy.com ...
Hi,

I can't figure out how to set multiple items in a ListBox to selected when
the listbox is in a User Control.

When the ListBox is set in directly into a form I can use the following:
listbox.SelectionMode = SelectionMode.MultiExtended;
listbox.SelectedIndex = 1;
listbox.SelectedIndex = 2;

But when I set the ListBox into a User Control, this doesn't work. I can
only set one item to selected.

Any help appreciated. TIA.

-Ted

Nov 17 '05 #3

P: n/a
ted
This doesn't work for me when I have the ListBox in a UserControl.

It works when I have it in a panel or directly on a form. I can select
multiple items in those cases. It's just when the ListBox is on a
UserControl that I can't set it to more than one item.

"Vitaly Zayko" <vitaly_at_zayko_dot_net> wrote in message
news:uF**************@TK2MSFTNGP15.phx.gbl...
Try this:
listBox.SetSelected(0, true);
ted wrote:
Hi,

I can't figure out how to set multiple items in a ListBox to selected
when the listbox is in a User Control.

When the ListBox is set in directly into a form I can use the following:
listbox.SelectionMode = SelectionMode.MultiExtended;
listbox.SelectedIndex = 1;
listbox.SelectedIndex = 2;

But when I set the ListBox into a User Control, this doesn't work. I can
only set one item to selected.

Any help appreciated. TIA.

-Ted

--
Vit Zayko

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.