473,563 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SetSelected for a listbox does not select multiple items.

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.Tabl es(2).Rows
Index = ValuesListBox.F indStringExact( SelectedValue(" VALUE_S"))
If Index >= 0 Then
ValuesListBox.S etSelected(Inde x, True)
End If
Next
Nov 21 '05 #1
2 2662
On 03/05/2005 Henry Padilla wrote:
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.Tabl es(2).Rows
Index = ValuesListBox.F indStringExact( SelectedValue(" VALUE_S"))
If Index >= 0 Then
ValuesListBox.S etSelected(Inde x, True)
End If
Next

Have you set the Listbox selectionMode to either multiSimple or
MultiExtended?
--
DaveG - Crawling along the learning curve.
Nov 21 '05 #2
"DaveG" <ne*******@dave g.no.nospam> wrote in message
news:jv******** ***********@new s4.e.nsc.no...
On 03/05/2005 Henry Padilla wrote: -- snip -- Have you set the Listbox selectionMode to either multiSimple or
MultiExtended?
--
DaveG - Crawling along the learning curve.


Yes, I did. And sorry for not posting feedback.

This happens if you SetSelected BEFORE the control is added to the form.
For some reason, when it is added to the form, it resets it's selections.

I put in a public "Setup" function and called it after the control was added
to the form and it works perfectly.

Tom P.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1133
by: Tim | last post by:
I have form with a ListBox. That ListBox is bound to a datasource. That ListBox has a SelectionMode set to Multi-Extended. When I try to programatically set multiple items selected via the SetSelected method, the items do not select IF THE FORM IS AN MDI CHILD. If the form is NOT and MdiChild, then the code works as expected. ANYONE seen...
3
2808
by: Andrew | last post by:
I'm having a major problem with a databound listbox in C#. In the constructor for the form I am trying to pre-select some of the items based in information in the database. When I step through the debugger it all seems to be working properly until the Load function is called, and then all my selections but 1 are unselected. Anybody had any...
4
5350
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname), column4 (Forename) and column5 (title). Columns 3,4 and 5 are not shown in the list box only the first two. DOB Name: &" "&&", "&
2
5735
by: Matt Sawyer | last post by:
Hi, I'm attempting to do a drag and drop operation from one listbox to another. I have my listboxes setup with SelectionMode = MultiExtended so that I can use the shift key, cntrl key, etc. to make multiple selections. The problem I am having is that when I use the shift key to select a range of items, I first click on one item (item gets...
3
2250
by: Peter Mancini | last post by:
I have a simple winform with a listbox on it. I dynamically load the box with integers (the years 1975 to present.) This works fine and I can see the box has all of the items present. I then do a mylistbox.SetSelected(0,true) so that the first item starts off selected. It is a MultiSimple listbox. What happens is nothing. The form draws...
1
8365
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's...
1
2229
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.
6
11900
by: Max | last post by:
I need some control that basically acts as a listbox, but allows each item to take up more then one line. I've tried adding a new item and putting in a vbCrLf in there, but that just comes out as a box on the same line. Is there some way of making the listbox show multiple lines for each item, or is there another control (3rd party maybe) that...
2
6935
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...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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...
1
7638
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...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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
0
923
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...

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.