Solved

VS 2005 ImageList Causing Error. My Application Will NOT Run!

Posted on 2006-07-06
6
820 Views
Last Modified: 2008-01-09
I am trying to use a treeview and imagelist. I began trying to implement the imagelist halfway through the project, when I wanted to provide images to the treeview and listview I'm using to display data.

I added 3 images to the imagelist.

I have set the treeview's imagelist property to the imagelist I added to the form.

Here is some sample code for when I programmatically add nodes to the treeview.

nd = TreeView1.TopNode.Nodes.Add("", reader.ReadString, 0)

Then I tried:

nd.SelectedImageIndex = 0


I keep getting the following error, and it never points to the offending line of code. It seems there is no code error AS I ONLY HAVE TO ADD AN IMAGELIST TO THE FORM AND ADD ONE IMAGE TO IT FOR THIS ERROR TO OCCUR.

"An error occurred creating the form. See Exception.InnerException for details. The error is: Index was outside the bounds of the array."


OK, I created a BRAND NEW project.

1) added a treeview and listview to the form

2) added an imagelist to the form

3) added one image to the imagelist

4) did not link the imagelist to a control

5) ran the application. ERROR

Here is a screencap of the error: http://img518.imageshack.us/img518/3956/error2vo.png

P.S. Sorry about the points, but EE limits the points I can give for this.
0
Comment
Question by:programmer1024
[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
6 Comments
 
LVL 8

Expert Comment

by:Shakti109
ID: 17054799

I can see that you state that you created a brand new project and added the controls/etc....But after replicating exactly your steps, the application starts up...

This may sound like a silly question but did you by any chance copy ANY code you had from the previous application into the new one?
0
 
LVL 4

Author Comment

by:programmer1024
ID: 17055397
>>I can see that you state that you created a brand new project and added the controls/etc....But after replicating exactly your steps, the application starts >>up...

>>This may sound like a silly question but did you by any chance copy ANY code you had from the previous application into the new one?

Nope. When I add the imagelist to a new project it will run.

Once I add an image to the imagelist, THAT is when it crashes.
0
 
LVL 4

Author Comment

by:programmer1024
ID: 17055497
OK, it seems my problem is solved.

Once I saved the project after adding the images to the imagelist, it worked. Very strange. It seems one has to save after adding images to the imagelist? Or maybe only I do? Or everyone else has autosave on??

0
 
LVL 8

Expert Comment

by:Shakti109
ID: 17057503

That's very strange indeed, no saving is necessary for it to run without error for any of the developers here at work(10 or so responded).

The only thing I can think of, is are you using images that are on a network share (or buried somewhere behind a very very deep path)?

This shouldnt affect it, because if you can "see" the images to use them in the first place, you both have access to them and they are available, BUT, odd things do happen occasionally.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 17105679
Closed, 125 points refunded.
Netminder
Site Admin
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

733 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