Link to home
Start Free TrialLog in
Avatar of huda_qadura
huda_qadura

asked on

fill listbox with images

hi
how can i fill a listbox with image items instead of text in c#? i've seen listboxes filles with images before.
huda
ASKER CERTIFIED SOLUTION
Avatar of aacool
aacool

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aacool
aacool

Easy impl of helper.openImage and helper.resizeImage
            // Open Image and return it - does not change size,etc.
            public Image openImage(string path)
            {
                  try
                  {
                        Bitmap bmp = new Bitmap(path);
                        m_img = (Image)bmp;
                        return m_img;
                  }
                  catch(Exception ex)
                  {
                        MessageBox.Show(ex.Message+"Path:"+path);
                        return (Image)null;
                  }
                  
            }
            public void resizeImage(Image src_image,ref Image newImg,Size size)
            {
                Bitmap bitmap = new Bitmap(size.Width, size.Height,src_image.PixelFormat);
                  Graphics new_g = Graphics.FromImage(bitmap);
                  new_g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                  new_g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                  new_g.DrawImage(src_image, 0, 0, bitmap.Width, bitmap.Height);
                  newImg = (Image)bitmap;
                  new_g.Dispose();                  
            }
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial