Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

ListView exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
yevron2@gmail.com - 05 Jul 2006 08:41 GMT
Hello,

When i am trying to remove the last item in a listview:

lstServers.Items.Remove(item);

i get the exception:

A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in system.windows.forms.dll

Additional information: Specified argument was out of the range of
valid values.

Does anyone know why that is?

Thanx,
Yael.
Joris Zwaenepoel - 05 Jul 2006 09:15 GMT
What is the type of "item"?  Is it an integer?

You get this error if you try to access an item with an index that is larger
then the iondex of the last item, for example if you have 5 items in the
listbox then they have indexes 0 to 4, and you will get this error if try to
acces an item using the value 5 as its index.

To remove the last item, try

lstServer.Items.remove(lstServer.Items.Count-1)

Joris

> Hello,
>
[quoted text clipped - 14 lines]
> Thanx,
> Yael.
yevron2@gmail.com - 05 Jul 2006 11:03 GMT
item is of type ListViewItem.

The item is taken from the selectedItems, and the list view does remove
it but it throws the exception.

> What is the type of "item"?  Is it an integer?
>
[quoted text clipped - 27 lines]
> > Thanx,
> > Yael.
yevron2@gmail.com - 05 Jul 2006 12:35 GMT
I happens when i do it from a pop up menu that i manually poped at the
lstServers_MouseDown.

Thanx for all your help!

> item is of type ListViewItem.
>
[quoted text clipped - 32 lines]
> > > Thanx,
> > > Yael.
rhaazy - 05 Jul 2006 21:15 GMT
> > > A first chance exception of type 'System.ArgumentOutOfRangeException'
> > > occurred in system.windows.forms.dll

> The item is taken from the selectedItems, and the list view does remove
> it but it throws the exception.

It sounds like you have some kind of recurssive behavior going on that
is causing it to try and remove it the first time but fails and when it
tries again it does it, or even vice versa...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.