473,321 Members | 1,622 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,321 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 2643
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.