C# ImageList problem

charlie

Member
Joined
Sep 9, 2004
Messages
10
Location
Barcelona (SPAIN)
Hello, .Net experts! This is my fist day in this forum and my first question as well. There I go:
Ive got a problem with an ImageList. I want to save 3 images within it. These images are 176x317. The problem is that the ImageList doesnt allow to put the "317" in the height of the images. Any ideas??

Thank you all in advance! :)
 
Hi charlie,
Youre kind of stuck with a max size of 255 x 255 for an image list. You might consider embeding the images in your program or loading them from files and storing them in an array in place of an image list.
 
Thanks for replying! :)
Yes, I realized that it is the max size of the ImageList.
Is there any way to save images for not loading them from HD? Another control or something...
 
I hope that someone will come along and translate this into C# for you.

First, add the images to your project with: Project | Add Existing Item then add your bitmap images.

From the Solution Explorer window select each bitmap and change its Build Action to Embedded Resource.

In your forms declaration section add: myBitmaps(2) as Bitmap or whatever you wish to call the array.

In your Forms Load sub add: Load_myBitmaps()

then:
Code:
    Private Sub Load_myBitmaps()
        Dim CurrentAssembly As String = Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString
        Dim bmpFile As IO.Stream
        Dim bmpFileName() As String = {"myBitmapName1.bmp", "myBitmapName2.bmp", "myBitmapName3.bmp"}
        Dim i as Integer
        For i = 0 To myBitmaps.GetUpperBound(0)
            bmpFile = Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(CurrentAssembly + "." + bmpFileName(i))
            myBitmaps(i) = New Bitmap(bmpFile)
        Next
    End Sub

Then use the bitmaps through your myBitmaps array.
PictureBox1.Image = myBitmaps(0)
 
Last edited by a moderator:
Back
Top