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 / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

ListBox crash when accessing SelectedIndex

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Valerie Hough - 26 May 2007 20:45 GMT
Can anyone please tell me how it is possible to get the following crash when
accessing ListBox.SelectedIndex property:

Message: Index was outside the bounds of the array.

Stack Trace:
at System.Windows.Forms.ListBox.ItemArray.GetEntryObject( Int32
virtualIndex, Int32 stateMask)
at System.Windows.Forms.ListBox.get_SelectedIndex()

It is not possible to use the ListBox.SelectedIndex = <some bad value> to
put a bad value in there (I've tried and this causes an immediate
exception),
so I just can't see how the above crash is possible

Can anyone please help?

Thanks in advance,
Valerie Hough
David Ching - 11 Jun 2007 01:29 GMT
> Can anyone please tell me how it is possible to get the following crash
> when accessing ListBox.SelectedIndex property:
>
> Message: Index was outside the bounds of the array.

What was the value of ListBox.SelectedIndex?

Just a guess... when you first init a listbox, I don't think an item is
selected.  In Win32 (not .NET), the selected index is -1.  So you can't use
that to select an item.  I'm not sure this is what is happening here.

-- David

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.