Solved

Listview limit

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

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…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

695 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