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
Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

860 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