Mulitselect listbox

E

Eric Schreiber

How can i get the itemdata form each item in a mulitselect list.

I made a loop but keep getting only the first value.

Dim i

Dim array1(100)

For i = 1 To aantalrecords

If ListBox1.GetSelected(i - 1).ToString = True Then

ListBox1.SelectedIndex = i - 1

mylist = ListBox1.SelectedItem

array1(i) = mylist.ItemData

End If

Next



can someone please help me out?



Eric
 
C

Cor

Hi Eric,

You think you made a loop but you did not,
You have to loop through the items from your listbox

Beneath some examples, roughly written so watch errors

I hope this helps?

Cor

something as for a winform
\\\
dim myarray(listbox1.selecteditems) as string
dim i as integer
for i = 0 to listbox1.selecteditems.count - 1
myarray(i) = listbox1.selecteditems(i).text
next
///
and for a webform
dim myarray(listbox1.items) as string
dim i as integer
for i = 0 to listbox1.items.count - 1
if listbox1.Items(i).selected then
myarray(i) = listbox1.selecteditems(i).text
end if
next
///
I hope this helps?

Cor
 
A

Armin Zingler

Cor said:
This is the worst quoting what you do here, using words from a
message

I have seen this more from you quoting and deleting the essential
things from a message.


He doesn't have to quote everything. The question is sufficient. Apart from
this, you should better complain about those 500:1 lines quotes and sending
the quote again and again and again and again and again....must I continue?

:-(
 
C

Cor

Hi Armin,
He doesn't have to quote everything.
Text from one of the first rows from one by you always needless sended extra
rows

On the other hand, the quotation should not be so short that it is unclear
to what the author is referring to, or so that it may even appear in a
totally different light.
The question is sufficient.

Who are you that you can say that, I think it is not. (you see think)
Apart from this, you should better complain about those 500:1 lines quotes and
sending the quote again and again and again and again and again....must I
continue?

I am me not aware that I do that, but when I do please point me on that.

Cor
 
A

Armin Zingler

Cor said:
Text from one of the first rows from one by you always needless
sended extra rows

On the other hand, the quotation should not be so short that it is
unclear to what the author is referring to, or so that it may even
appear in a totally different light.

Herfried's answer referred to the question. Why should he quote the code
also?
Who are you that you can say that, I think it is not. (you see
think)

The question is not "who" I am. The question is if it's right or not. He
didn't refer to the code, so it's not necessary to quote it. Consequently it
is sufficient to quote the question. That's what remains and that's the
logical explanation, independent from "who" writes it.

continue?

I am me not aware that I do that, but when I do please point me on
that.

I think you misunderstood. I did not say you *do* complain, I said you do
*not* complain.
 
C

Cor

Armin,
Herfried's answer referred to the question. Why should he quote the code
also?

There is not spoken about an itemdata property in the question.

If Herfried had quoted right than his answer was maybe right but still not
correct.
including the quoting it had minimal to be.

------------------
How can i get the itemdata form each item in a mulitselect list. ...................
array1(i) = mylist.ItemData

There is no 'ItemData' property in VB.NET.
 
A

Armin Zingler

Cor said:
There is not spoken about an itemdata property in the question.

If Herfried had quoted right than his answer was maybe right but
still not correct.
including the quoting it had minimal to be.

If you want the full text, read the initial message.

EOT for me. :)
 
H

Herfried K. Wagner [MVP]

* "Armin Zingler said:
He doesn't have to quote everything. The question is sufficient. Apart from
this, you should better complain about those 500:1 lines quotes and sending
the quote again and again and again and again and again....must I continue?

Yes, please... Make a 100,000 line quote...

;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top