Solved

Picturebox & ImageList

Posted on 2006-06-21
6
2,994 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

16 Experts available now in Live!

Get 1:1 Help Now