Windows Forms ImageList ArgumentOutOfRangeException: InvalidArgument=Value of '1' is not valid for 'index'.

Answered Windows Forms ImageList ArgumentOutOfRangeException: InvalidArgument=Value of '1' is not valid for 'index'.

  • Friday, April 13, 2012 6:48 AM
     
      Has Code

    Hi all,

    I have a Windows Forms application, a form with an ImageList containing 8 images loaded at design time.

    The ImageList is used in runtime in this way:

    private int IMG_GREEN = 1;
    ...
    pictureBoxStatus.Image = imageList1.Images[IMG_GREEN];
    ...

    It works fine at most computers (hundreds), but it raises exception at only one.

    Do you have any idea, where can be a problem?

    Damaged the exe file?

    Wrong assembly of .NET framework?

    Virus?

    Thanks

    Jiri

All Replies

  • Friday, April 13, 2012 7:01 AM
     
     Answered

    hi,

    did you try re-installing it?

    if it is 1 in hundreds, it is not going to be a coding error.


    Regards, Nico

  • Friday, April 13, 2012 7:12 AM
     
     

    Not yet, I'am not personally responsible for the deployment, so I'am waiting for response from my colleagues.

    Jiri

  • Friday, April 13, 2012 7:17 AM
     
     

    Have you done the imageList1.Add("xxxxx") before the

    pictureBoxStatus.Image = imageList1.Images[IMG_GREEN];
    ?

    List the full function here if you want.

    chanmm


    chanmm

  • Friday, April 13, 2012 12:42 PM
     
     

    Have you done the imageList1.Add("xxxxx") before the

    pictureBoxStatus.Image = imageList1.Images[IMG_GREEN];
    ?


    No, the imagelist is filled in design time with eight images. 

    Jiri

    • Edited by jirpun Friday, April 13, 2012 12:43 PM
    •  
  • Monday, April 16, 2012 5:40 AM
     
     

    HI,

    Your imageslist is filled at design time / runtime?

  • Monday, April 16, 2012 7:23 AM
     
     

    HI,

    Your imageslist is filled at design time / runtime?

    At design time.

  • Tuesday, April 17, 2012 3:02 AM
    Moderator
     
     

    Hi jirpun,

    Any updates from your colleagues? The exception means the index 1 is outside the allowable range of images. Try @Nico's suggestion, reinstall it.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.