Solved

Picturebox & ImageList

Posted on 2006-06-21
6
3,009 Views
Last Modified: 2008-01-09
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];

//works
pictureBoxOption1.Image =Image.FromFile("rollover.png");
}

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

thanks in advance
0
Comment
Question by:ramrocket
  • 3
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16953675
1) What is the size for the images indicated by the ImageList?

2) What is the SizeMode for the PictureBox?

Bob
0
 

Author Comment

by:ramrocket
ID: 16953692
170x90 & normal
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16953698
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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:ramrocket
ID: 16953771
I have done the 1st option - it didnt work.  how do you use resource and programactically retrieve the image?
0
 
LVL 11

Accepted Solution

by:
vo1d earned 100 total points
ID: 16953841
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.
try:
yourappnamespace.Properties.Resources.YourImageName

the return type is bitmap.
0
 

Author Comment

by:ramrocket
ID: 16953872
I use embedd resources.

thanks that works
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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