Click to See Complete Forum and Search --> : Population a listBox


Quell
March 14th, 2005, 06:58 PM
hello.
how do i populate a listbox with data?
thnx

Zeb
March 14th, 2005, 07:58 PM
listBox1.Items.Add("abc")

Quell
March 16th, 2005, 09:08 AM
hey, how do i also check what item is selected. I got a function that handles the double click, how do i get whihc item in the lsit box is selected?(number of it...index of it if u may)

DeepButi
March 16th, 2005, 09:34 AM
Quell,
use ListView1.SelectedItems collection:

ListView1.SelectedItems.Count
ListView1.SelectedItems(i)

Hope it helps

Ajay Vijay
March 16th, 2005, 10:18 AM
Quell,
use ListView1.SelectedItems collection:
...

Hope it helpsDid you realize what the OP is asking in the first place?
He is asking about ListBox and not ListView. List box holds (commonly) only one column, and list view (generally) holds more than 1 columns. List view is like Detailed view in Windows explorer, whereas list-box is like fonts list in Font dialogs (which are actually Combo-boxes).

If you actually meant ListBox, instead of ListView, your code is perfect! :thumb:

DeepButi
March 16th, 2005, 10:31 AM
Oooops! true ... :blush: :blush: one hundred milion times sorry. I meant ListBox1 :blush: :blush: .

(Although nothing prevents you from using ListView1 as the ListBox name :p :p :p )

ss_gurmeet
March 16th, 2005, 10:46 AM
If u want do this i think the following code must be useful

Dim i, a As Integer
For i = 0 To ListBox1.SelectedItems.Count() - 1
'Do Ur processing here what do you want
a=ListBox1.SelectedItems(i)
'a hold the current i element's index in main listbox1 Array
Next
Hope it is useful 4 u

Best of Luck :thumb:

Regards
Gurmeet :D