ListView and DisplayIndex

K

Ken

I am adding items to a listview and I get an exception that seems to be
random.

"500 is not a valid value for displayindex"

I have searched the web looking for others with this problem and have found
a few. The problem is: I've found no real explanation/solution to the
problem - yet.

Someone has to know what this is - and how to handle it.

Is it a bug in vb.net?
Can it be swatted?

Thanks, Ken
 
A

Armin Zingler

Ken said:
I am adding items to a listview and I get an exception that seems to
be
random.

"500 is not a valid value for displayindex"

I have searched the web looking for others with this problem and have
found a few. The problem is: I've found no real explanation/solution
to the problem - yet.

Someone has to know what this is - and how to handle it.

Is it a bug in vb.net?
Can it be swatted?

How many items are in the list? The index is 0-based. With 500 items, the
maximum index is 499.

Armin
 
K

Ken

Yes. The number of items in the list is 500 when I get the count. However,
the max index is 499 since it is 0-based. This has been tested and is
accurate. The problem still remains

Ken
 
H

Herfried K. Wagner [MVP]

Ken said:
Yes. The number of items in the list is 500 when I get the count. However,
the max index is 499 since it is 0-based. This has been tested and is
accurate. The problem still remains

Please post relevant parts of the code.
 
K

Ken

I think you are talking about the code below. It is executed after each
addition to the listview.

If frmComm1.ListView1.Items.Count > 500 Then
frmComm1.ListView1.Items.RemoveAt(500)

I do not get the error every time 500 items are in the listview, the error
occurs randomly. The program could run for hours, even days before an error
occurs.

I found something here that seems to be the same type of problem.
http://service1.symantec.com/SUPPOR...Image&ver=7.x&src=sg&pcode=dimage&svy=&csm=no

Thanks for your help, this has been haunting me for a couple of months now.

Ken
 

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