Solved

Listview limit

Posted on 2004-03-20
4
758 Views
Last Modified: 2012-08-14
Is there a limit to the amount of rows in a list view.

I have a routine that processes through all items in a listview correctly until it comes to index 1363 where .NET is telling me this is out of range?  Is this true?

If it is, is there anyway to get around this?

Thanks,
Paul
0
Comment
Question by:trancetopia
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Timbo87
ID: 10642054
This sounds like an off by one bug. If you're using a loop, try setting the condition minus 1. For example:

Dim i As Integer
For i = 0 To variable - 1
...
Next
0
 

Author Comment

by:trancetopia
ID: 10642093
Hi Timbo,

Here is the code i'm using.  Sorry should have mentioned this earlier as there are 1612 rows inserted my listview but the following line failes at 1363 each time I run it.

LItem = listMessages.Items(i)

Code:
Dim i As Integer
            Dim LItem As ListViewItem
            Dim intIndex As Integer

            For i = 0 To listMessages.Items.Count - 1

                LItem = listMessages.Items(i)
                If LItem.Checked = True Then
                    intIndex = LItem.Index
                    txtStatus.Text = txtStatus.Text & "REMOVING: " & LItem.Text & vbCrLf

                    '## Delete Email ##
                    inbox.DeleteMessage(CInt(LItem.Text), True)

                    '## Delete from listMessages ##
                    LItem.Remove()
                End If

            Next
0
 
LVL 15

Accepted Solution

by:
Timbo87 earned 50 total points
ID: 10642178
The problem is that every time an item is removed, listMessages.Items.Count decreases by one so eventually when the i value exceeds the number of remaining list view items, the exception is thrown.
0
 

Author Comment

by:trancetopia
ID: 10642188
Feel like a fool for overlooking that.. :(   It's so obvious now you have pointed it out.  Many thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now