Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 782
  • Last Modified:

Listview limit

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
trancetopia
Asked:
trancetopia
  • 2
  • 2
1 Solution
 
Timbo87Commented:
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
 
trancetopiaAuthor Commented:
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
 
Timbo87Commented:
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
 
trancetopiaAuthor Commented:
Feel like a fool for overlooking that.. :(   It's so obvious now you have pointed it out.  Many thanks.
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now