473,769 Members | 6,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Selecti onMode = SelectionMode.M ultiExtended;
listbox.Selecte dIndex = 1;
listbox.Selecte dIndex = 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 22563
Try this:
listBox.SetSele cted(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.Selecti onMode = SelectionMode.M ultiExtended;
listbox.Selecte dIndex = 1;
listbox.Selecte dIndex = 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************ *********@sbcgl obal.net> wrote in message
news:XO******** ********@newssv r21.news.prodig y.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.Selecti onMode = SelectionMode.M ultiExtended;
listbox.Selecte dIndex = 1;
listbox.Selecte dIndex = 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_zayk o_dot_net> wrote in message
news:uF******** ******@TK2MSFTN GP15.phx.gbl...
Try this:
listBox.SetSele cted(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.Selecti onMode = SelectionMode.M ultiExtended;
listbox.Selecte dIndex = 1;
listbox.Selecte dIndex = 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
3561
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 seem to work. Only the last clicked item appears selected (highlighted) in the display and the return from info_selection only ever contains the last 2 items, rather than all the items I have control-clicked. It's odd, because if I set up the...
4
11264
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 at the top of the list moving down towards the bottom. The problem I was having was that the <select> control was scrolling back to the top of the page after the postback and the user would lose their place in the <select> control forcing them to...
3
5628
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 listbox on databind. the problem is this only selects the last row "840" -- i would imagine this
0
2051
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 to highlight them in the listbox within the datagrid control......... Thanks, Bill... >-----Original Message-----
1
2248
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 the list.
2
2669
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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For Each SelectedValue In ColumnInfo.Tables(2).Rows Index = ValuesListBox.FindStringExact(SelectedValue("VALUE_S")) If Index >= 0 Then
5
2365
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 does not have SelectionMode : listbox.SelectionMode = SelectionMode.MultiExtended;
1
4030
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 are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
2
6950
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 come across a way to set the listbox value to only 1 at a time, but need multiple toggle buttons to be on their corresponding listbox item values to be selected. Thanks!
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.