ListView and DisplayIndex

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken

    ListView and DisplayIndex

    I am adding items to a listview and I get an exception that seems to be
    random.

    "500 is not a valid value for displayindex"

    I have searched the web looking for others with this problem and have found
    a few. The problem is: I've found no real explanation/solution to the
    problem - yet.

    Someone has to know what this is - and how to handle it.

    Is it a bug in vb.net?
    Can it be swatted?

    Thanks, Ken


  • Armin Zingler

    #2
    Re: ListView and DisplayIndex

    "Ken" <ks3ss@s32443t. com> schrieb[color=blue]
    >I am adding items to a listview and I get an exception that seems to
    > be
    > random.
    >
    > "500 is not a valid value for displayindex"
    >
    > I have searched the web looking for others with this problem and have
    > found a few. The problem is: I've found no real explanation/solution
    > to the problem - yet.
    >
    > Someone has to know what this is - and how to handle it.
    >
    > Is it a bug in vb.net?
    > Can it be swatted?[/color]

    How many items are in the list? The index is 0-based. With 500 items, the
    maximum index is 499.

    Armin

    Comment

    • Ken

      #3
      Re: ListView and DisplayIndex

      Yes. The number of items in the list is 500 when I get the count. However,
      the max index is 499 since it is 0-based. This has been tested and is
      accurate. The problem still remains

      Ken

      "Armin Zingler" <az.nospam@free net.de> wrote in message
      news:eFoNDziWFH A.3996@TK2MSFTN GP09.phx.gbl...[color=blue]
      > "Ken" <ks3ss@s32443t. com> schrieb[color=green]
      > >I am adding items to a listview and I get an exception that seems to
      > > be
      > > random.
      > >
      > > "500 is not a valid value for displayindex"
      > >
      > > I have searched the web looking for others with this problem and have
      > > found a few. The problem is: I've found no real explanation/solution
      > > to the problem - yet.
      > >
      > > Someone has to know what this is - and how to handle it.
      > >
      > > Is it a bug in vb.net?
      > > Can it be swatted?[/color]
      >
      > How many items are in the list? The index is 0-based. With 500 items, the
      > maximum index is 499.
      >
      > Armin[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: ListView and DisplayIndex

        "Ken" <ks3ss@s32443t. com> schrieb:[color=blue]
        > Yes. The number of items in the list is 500 when I get the count. However,
        > the max index is 499 since it is 0-based. This has been tested and is
        > accurate. The problem still remains[/color]

        Please post relevant parts of the code.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • Ken

          #5
          Re: ListView and DisplayIndex

          I think you are talking about the code below. It is executed after each
          addition to the listview.

          If frmComm1.ListVi ew1.Items.Count > 500 Then
          frmComm1.ListVi ew1.Items.Remov eAt(500)

          I do not get the error every time 500 items are in the listview, the error
          occurs randomly. The program could run for hours, even days before an error
          occurs.

          I found something here that seems to be the same type of problem.


          Thanks for your help, this has been haunting me for a couple of months now.

          Ken

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:O9vNcCjWFH A.2572@TK2MSFTN GP14.phx.gbl...[color=blue]
          > "Ken" <ks3ss@s32443t. com> schrieb:[color=green]
          > > Yes. The number of items in the list is 500 when I get the count.[/color][/color]
          However,[color=blue][color=green]
          > > the max index is 499 since it is 0-based. This has been tested and is
          > > accurate. The problem still remains[/color]
          >
          > Please post relevant parts of the code.
          >
          > --
          > M S Herfried K. Wagner
          > M V P <URL:http://dotnet.mvps.org/>
          > V B <URL:http://classicvb.org/petition/>
          >[/color]


          Comment

          Working...