Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Icon from ImageList

Icon from ImageList

Scheduled Pinned Locked Moved C#
questionlearning
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Derek Price
    wrote on last edited by
    #1

    I have an ImageList that I created using Icon (*.ico) files. I would like to extract an image as an Icon, but casting doesn't work: Icon test = (Icon)imgList.Images[1]; I know I can access the original .ico file from disk or resource, but since it was already loaded in an ImageList, I thought this would be an easier method. Does anyone know if this is possible? Thanks!

    R 1 Reply Last reply
    0
    • D Derek Price

      I have an ImageList that I created using Icon (*.ico) files. I would like to extract an image as an Icon, but casting doesn't work: Icon test = (Icon)imgList.Images[1]; I know I can access the original .ico file from disk or resource, but since it was already loaded in an ImageList, I thought this would be an easier method. Does anyone know if this is possible? Thanks!

      R Offline
      R Offline
      Rupel
      wrote on last edited by
      #2

      the Bitmap class has a GetHicon() function. and the Icon class has an FromHandle(IntPtr) static function. so, maybe something like

      Icon test = Icon.FromHandle(GetHicon(imgList.Images[1]));

      does it? :wq

      D 1 Reply Last reply
      0
      • R Rupel

        the Bitmap class has a GetHicon() function. and the Icon class has an FromHandle(IntPtr) static function. so, maybe something like

        Icon test = Icon.FromHandle(GetHicon(imgList.Images[1]));

        does it? :wq

        D Offline
        D Offline
        Derek Price
        wrote on last edited by
        #3

        Thanks! Based on your suggestion, here's what worked: Icon test = Icon.FromHandle(new Bitmap(imgList.Images[1]).GetHicon()); Thanks again! Derek

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups