Solved

Listview limit

Posted on 2004-03-20
4
763 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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