Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / November 2006

Tip: Looking for answers? Try searching our database.

adding listbox selected items

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lord.zoltar@gmail.com - 21 Nov 2006 20:02 GMT
Hello
I'm trying to programmatically set a listbox to have several items
selected when it is loaded. Which items are selected is based on a
saved user setting.
Right now, I'm trying:
Me.my_ListBox.SelectedIndices.Add(item)
This throws exceptions.
What is a safe way to add indices to the SelectedIndices list?
Kerry Moorman - 21 Nov 2006 21:00 GMT
lord.zoltar,

From your example, it looks like you have the items that should be selected.
In that case:

    Me.my_ListBox.SelectedItems.Add(item)

Kerry Moorman

> Hello
> I'm trying to programmatically set a listbox to have several items
[quoted text clipped - 4 lines]
> This throws exceptions.
> What is a safe way to add indices to the SelectedIndices list?
Tim Patrick - 21 Nov 2006 21:13 GMT
You can use the ListBox control's SetSelected method. Pass it the position
of the list item, and a boolean value, True in this case.

   ListBox1.SetSelected(itemPosition, True)

Make sure that you have also set the SelectionMode property for the control
as needed.

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

> Hello
> I'm trying to programmatically set a listbox to have several items
[quoted text clipped - 4 lines]
> This throws exceptions.
> What is a safe way to add indices to the SelectedIndices list

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.