Solved

How to programatically select an item in a multi-exteded listbox

Posted on 2006-06-27
4
205 Views
Last Modified: 2010-04-23
My listbox is fully populated, and based upon certain program conditions, I want to select certain (multiple) items programatically.

I would expect something like this to work:
     LB_Clients.Items(i).selected = True
but it simply gives me an error message


Thanks in advance for your help.

Extra points due to urgency
0
Comment
Question by:bobdowdy
  • 2
4 Comments
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 250 total points
ID: 16992565
Use ListBox.SetSelected Method to select/unselect items in multiple-selection ListBox.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.setselected.aspx
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16992590
ListBox1.SelectedIndex = 1
i.e

ListBox1.SelectedIndex = i
0
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 250 total points
ID: 16992621
 'Syntax: ListBox1.SetSelected(index,boolean value)
       
        ListBox1.SetSelected(1, True) 'To select the item
        ListBox1.SetSelected(1, False) 'To unselect the item
0
 

Author Comment

by:bobdowdy
ID: 16992815
Thanks a million - I split points because while alex was first, pradeep provided answer instead of reference. Thanks again.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question