• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3071
  • Last Modified:

Picturebox & ImageList

I have a picturebox that I want to swap image during hover, leave, enter.  I placed my images onto an ImageList set at 170x90 and colordepth32bit.  When the hove code excute, the image is distorted and doesnt display well.

code snippit:
private void OnMouseHover(object sender, System.EventArgs e)
//does not work - images distorted
pictureBoxOption1.Image = imageList.Images[1];

pictureBoxOption1.Image =Image.FromFile("rollover.png");

I dont want to read from file at runtime.  How do I fix this?

thanks in advance
  • 3
  • 2
1 Solution
Bob LearnedCommented:
1) What is the size for the images indicated by the ImageList?

2) What is the SizeMode for the PictureBox?

ramrocketAuthor Commented:
170x90 & normal
i assume you are using net2, correct?
that is a known strange behaviour of the net2 imagelist.
try this:
setup a clean new imagelist with the size and the colordepth you need BEFORE you insert the images to it.

if that dont work, use a resource file instead.
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

ramrocketAuthor Commented:
I have done the 1st option - it didnt work.  how do you use resource and programactically retrieve the image?
in your projectpath, goto Properties. there is a resources.resx file.
doubleclick on it.
on the designer of that file, goto Add Resource->Add Existing File... .
choose the images you need.
after adding it, you got acces to that images with its name as property.

the return type is bitmap.
ramrocketAuthor Commented:
I use embedd resources.

thanks that works
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now