Solved

Picturebox & ImageList

Posted on 2006-06-21
6
2,998 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# GridRow get Old/New Value 1 55
Check my code out(2) 2 53
Data is not showing from images 15 36
Reset asp.net login password 4 25
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now