.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 12th, 2004, 09:18 AM
pradeep_gj pradeep_gj is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 pradeep_gj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VB.NET : how to fetch list box selected values (more than one) into an array

I have a VB.Net listbox on a stand alone application. Not a web app. I want to fetch the values of the selected items (multiselect extended is set on), into an array.

Please help.

Reply With Quote
  #2  
Old March 12th, 2004, 11:35 AM
bombaywala bombaywala is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Arlington, VA
Posts: 191 bombaywala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 24 m 37 sec
Reputation Power: 5
Send a message via AIM to bombaywala Send a message via MSN to bombaywala Send a message via Yahoo to bombaywala
Post your code....

Reply With Quote
  #3  
Old March 13th, 2004, 01:46 AM
sano sano is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Redmond, WA
Posts: 218 sano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Quote:
Originally Posted by pradeep_gj
I have a VB.Net listbox on a stand alone application. Not a web app. I want to fetch the values of the selected items (multiselect extended is set on), into an array.

Please help.


You need to iterate through all of the ListItems in the collection and check the Selected property to see which ones are selected.

I'm not sure why you want to put the values in an array though.

Reply With Quote
  #4  
Old March 16th, 2004, 09:25 AM
pradeep_gj pradeep_gj is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 pradeep_gj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Dim strArrSelectedEmployees(lstEmployees.SelectedItems.Count - 1) As String
Dim intCounter As Integer
Dim intSelectedCounter As Integer = 0

For intCounter = 0 To lstEmployees.Items.Count - 1
If lstEmployees.GetSelected(intCounter) Then

strArrSelectedEmployees(intSelectedCounter) = lstEmployees.GetItemText(lstEmployees.Items(intCounter))
intSelectedCounter = intSelectedCounter + 1
End If
Next

This code works, and gets the text of the selected items into the array. But i am not able to fetch the value instead of the text. Any suggestions?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > VB.NET : how to fetch list box selected values (more than one) into an array


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT