473,372 Members | 1,054 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,372 software developers and data experts.

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.Tables(2).Rows
Index = ValuesListBox.FindStringExact(SelectedValue("VALUE _S"))
If Index >= 0 Then
ValuesListBox.SetSelected(Index, True)
End If
Next
Nov 21 '05 #1
2 2646
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.Tables(2).Rows
Index = ValuesListBox.FindStringExact(SelectedValue("VALUE _S"))
If Index >= 0 Then
ValuesListBox.SetSelected(Index, 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*******@daveg.no.nospam> wrote in message
news:jv*******************@news4.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
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...
3
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...
4
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),...
2
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...
3
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...
1
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...
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...
6
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...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.