More than one image in listimage causes error

GrexD

Well-known member
Joined
Mar 5, 2008
Messages
95
Programming Experience
Beginner
Another odd one for me...

I have a listview control and an imagelist control. The imagelist is used for smallicons (16X16) and the listview is showing details. Last week I added 1 16X16 bitmap to it and all was well. The image is displayed on 1 of 10 items at best. No problems what so ever.

Now, I add a second image, also a 16X16 bitmap, and the form won't load. The error is "Index outside the bounds of the array". I remove the image and go back to the single image in the listimage and the form loads. Add in the second one and the error occurs again.

I don't even get to the point of trying to assign the new image to a listitem. The form won't even load. I've tried looking everywhere for where I can increase the size of the image array.

One hour of my life wasted on this so far...:mad:
 
I didn't know you could throw an error in design time. It won't load at run-time.

I added a second imagelist and did not use it with any other control but just tried to add images and run the application. I had the same problem. I can't add more than one image to it from the properties window. However, I did find that I can add a second image with code in the Form_Load event. Very odd.

I have another application that was converted from a VB6 project. In VB6 I added 4 images to an imagelist control. VB.Net converted the app with the images and it runs fine.
 
I've attached images.zip (I hope) these are both 16X16 bitmap files. I also converted them to jpg and tried to load them in the imagelist with the same results.

Good luck.
 

Attachments

  • images.zip
    841 bytes · Views: 31
I experience no problems loading them into an imagelist. I would like to point out:

1) the Hand image is 14x16, not 16x16
2) The images differ in bit depth
3) do not use jpeg compression for screenshots or other on-screen glyphs. JPEG is designed ONLY for photos or other images where there are gradual changes in contrast/colour. For use in your app, the images will be turned back into a bmp, so the only thing you lose by adding the jpeg step is quality, and you don't gain anything
 
I experience no problems loading them into an imagelist. I would like to point out:

1) the Hand image is 14x16, not 16x16

This shouldn't matter, and I guess it didn't for you.
2) The images differ in bit depth

Does this matter?
3) do not use jpeg compression for screenshots or other on-screen glyphs. JPEG is designed ONLY for photos or other images where there are gradual changes in contrast/colour. For use in your app, the images will be turned back into a bmp, so the only thing you lose by adding the jpeg step is quality, and you don't gain anything

I don't use JPEG normally. This was an act of desperation. I'm wondering if it is because I load them off a network drive. I'll need to test this later today.
 
I tried putting both images in the root of my C: drive and loading them from there. I received the same results. Very curious. What version are you running. I'm using...

Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727 SP1
Installed Edition: Standard
Microsoft Visual Basic 2005
Microsoft Visual Studio 2005 Standard Edition - ENU Service Pack 1
 
Last edited:
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727 SP1

Installed Edition: Professional

Microsoft Visual Basic 2005

Microsoft Visual C# 2005

Microsoft Web Application Projects 2005
Version 8.0.50727.762

Crystal Reports
Crystal Reports for Visual Studio 2005


Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1 (KB926601)
This service pack is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this service pack will be uninstalled automatically.
For more information, visit Description of Visual Studio 2005 Service Pack 1

Oracle Developer Tools for Visual Studio .NET 10.2.0.2.20
Oracle Developer Tools for Visual Studio .NET Copyright (c) 2006

Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB937061)
This Security Update is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this Security Update will be uninstalled automatically.
For more information, visit Description of the security update for the Microsoft Visual Studio 2005 Service Pack 1 development platform

Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB947738)
This Security Update is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this Security Update will be uninstalled automatically.
For more information, visit MS08-052: Description of the security update for GDI+ for Visual Studio 2005 Service Pack 1: September 9, 2008
 
This shouldn't matter, and I guess it didn't for you.
It stretches the image?


Does this matter?
It didnt for me

I don't use JPEG normally. This was an act of desperation. I'm wondering if it is because I load them off a network drive. I'll need to test this later today.
Can VS' icon editor load them? can you save them as icons into resources?
 
This shouldn't matter, and I guess it didn't for you.
It stretches the image?

By "shouldn't matter" I mean it should not generate an error

Can VS' icon editor load them? can you save them as icons into resources?

I sort of needed to move on. I could no longer justify the time of trying to load the image at design-time when loading it at run-time works. It will remain one of the mysteries that is VS2005.

The main reason I had to move on was because the dead-line to launch the app was yesterday. As of today it is being used by 9 people in the company and only one minor bug report so far. This morning one woman who is using the app came by my desk with one of the print-outs from the app and went on and on about how much she loved it. If only all launches were that well received.
 
Good to know someone out there is writing code that users can and do appreciate.. Most of my stuff performs such a low-level function that only I know of its existence and the hoops it jumps through to help the business function.. Priority on UI apps takes second place to automation :/

As noted, I experienced zero problems loading your images or using them in an app. You may want to review the software installed on your development machine (e.g. format it ;) )
 
Back
Top