473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to select multiple items in ListBox control

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
3 22539
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: theoryboy | last post by:
I'm trying to implement multiple selection functionality in a Tix Hlist using a control-click. I've bound control-click to a function that uses selection_set to add to the selection, but it doesn't...
4
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting...
3
by: mike | last post by:
How do i do the following: lbCountries.SelectedValue = "826"; lbCountries.SelectedValue = "840"; Basically i've set the selectmode to multiple and want to select multiple values of the...
0
by: bill yeager | last post by:
Duray, it helps in regards to knowing how to get the items that were selected in the lisbox, but I'm going in reverse --- after I get the items from the db that were selected, I'd like to be able...
1
by: sab | last post by:
Hi, We have a web form with a listbox. The listbox is a multiple select listbox and has data that looks something like: ALL Unit 1 Unit 2 Unit 3 Note: "ALL" is always the first item in...
2
by: Henry Padilla | last post by:
I'm trying to select multiple items in a listbox and the demo from the help file is not working. What do I do to select multiple items in a listbox? Code sample below. Tom P. ...
5
by: chad | last post by:
Hi, Im new to C#, and I have a question. I can't figure out how to set the listbox control top select multiple items in a ListBox. I have tried using the following code, but C# VS 2005 PE...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
2
by: 6afraidbecause789 | last post by:
Hi - Has anyone ever used toggle buttons to select items in a listbox? I'd like to put about 24 toggle buttons on an unbound form that select or deselect items in a multiple select listbox. I've...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.