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. Image on Windowsform ListBox

Image on Windowsform ListBox

Scheduled Pinned Locked Moved C#
graphicshelpquestion
4 Posts 4 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.
  • P Offline
    P Offline
    picasso2
    wrote on last edited by
    #1

    Can anyone help me understand this. not too much luck finding anything in google? using the following code to display a image in a button works fine button1.Image = global::AppInfo.Properties.Resources.MyImage; But if I trying to display the image on a windows Form listbox, it does not work listBox3.Items.Add(global::AppInfo.Properties.Resources.MyImage); This only displays "System.Drawing.Bitmap" text many thanks in advanced

    D L B 3 Replies Last reply
    0
    • P picasso2

      Can anyone help me understand this. not too much luck finding anything in google? using the following code to display a image in a button works fine button1.Image = global::AppInfo.Properties.Resources.MyImage; But if I trying to display the image on a windows Form listbox, it does not work listBox3.Items.Add(global::AppInfo.Properties.Resources.MyImage); This only displays "System.Drawing.Bitmap" text many thanks in advanced

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It's because the ListBox control doesn't render images on it's own. You have to custom draw each item in the ListBox yourself. See ListBox.DrawItem Event (System.Windows.Forms) | Microsoft Docs[^]

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      1 Reply Last reply
      0
      • P picasso2

        Can anyone help me understand this. not too much luck finding anything in google? using the following code to display a image in a button works fine button1.Image = global::AppInfo.Properties.Resources.MyImage; But if I trying to display the image on a windows Form listbox, it does not work listBox3.Items.Add(global::AppInfo.Properties.Resources.MyImage); This only displays "System.Drawing.Bitmap" text many thanks in advanced

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        If you add it to a listbox as an item, it will try to find a string-representation of your object. The thing it is displaying means it is working, and correctly. If you want images TO the items, try the Listbox.ImageList. There's an example on MSDN.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        1 Reply Last reply
        0
        • P picasso2

          Can anyone help me understand this. not too much luck finding anything in google? using the following code to display a image in a button works fine button1.Image = global::AppInfo.Properties.Resources.MyImage; But if I trying to display the image on a windows Form listbox, it does not work listBox3.Items.Add(global::AppInfo.Properties.Resources.MyImage); This only displays "System.Drawing.Bitmap" text many thanks in advanced

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          You may get more helpful replies here if you describe what the bitmaps you want to display are ... are they icons; do they vary in size, etc. ? Start here: [^] and figure out: 1. would using a ListView or DatagridView be a better choice ... if not ... 2. would the facility to use an 'ImageList with the ListView do what you want ... if not ... 3. are you willing to take on drawing the graphics yourself ... sub-classing the ListView and owner-drawing ... see: [^]

          «Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

          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