Solved

Picturebox & ImageList

Posted on 2006-06-21
6
3,015 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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