Solved

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

Posted on 2006-07-06
6
815 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now