Solved

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

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# code editing and collaboration 3 115
C# DataGridView_RowsAdded event not firing 1 75
Plain Text Editor for iPad 6 77
backup program with robocopy 6 22
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.
This is about my first experience with programming Arduino.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

809 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