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. Visual Basic
  4. Icon loading for listviews (.ico files)

Icon loading for listviews (.ico files)

Scheduled Pinned Locked Moved Visual Basic
graphicshelpcsharpdesign
1 Posts 1 Posters 0 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.
  • O Offline
    O Offline
    Oneiroid
    wrote on last edited by
    #1

    I am encountering the 'black icon' issue when loading .ico files into an ImageList for use with a ListView. If I load the icons into the ImageList as design-time, and pull them out with ' Create icon from ImageList Public Function AssignIcon(ByVal ImgList As ImageList, ByVal indx As Int32) Dim objBitmap As Bitmap Dim objIcon As Icon objBitmap = New Bitmap(ImgList.Images(indx)) objIcon = System.Drawing.Icon.FromHandle(objBitmap.GetHicon) Return objIcon End Function the icons are visible but any transparency is replaced with black. If I load the the ImageList at runtime, referencing icons which I've declared as embedded resources, with either: Dim ico0 As New Icon(System.Reflection.Assembly.GetExecutingAssembly._ GetManifestResourceStream("APKK.icnCD_16x16.ico")) ImgList.Images.Add(ico0) or Dim ico0 As New Icon(Me.GetType(), "icnCD_16x16.ico") ImgList.Images.Add(ico0) ALL I get is black boxes. Setting other icons without going through an imagelist (like me.icon) using either of the two above code snippets displays the icon perfectly and preserves the transparency. But again, if I were to pull my icon out of an imagelist to set me.icon, it would not display correctly. So I know it is possible that I can correctly display icons in my application when I do not use an ImageList. Is there any way I can assign an icon to a ListViewItem without using an ImageList? I suspect the answer is yes, but only by overriding the ListView class, and I have no idea where to start with that. Perhaps there is a special technique which I've overlooked for loading the ImageList? I like my icons as they are, and don't really relish the thought of manually turning them into bitmaps... Any help appreciated! Let me know if more info is required. I am using VB.Net 2003. Thank you!

    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