Solved

Listview limit

Posted on 2004-03-20
4
770 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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