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. drawing an icon on a form

drawing an icon on a form

Scheduled Pinned Locked Moved C#
graphicsquestioncsharpvisual-studio
3 Posts 2 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.
  • S Offline
    S Offline
    Senkwe Chanda
    wrote on last edited by
    #1

    Hi guys, I'm trying to draw an icon onto the surface of a form. What I do is create the icon in the bitmap editor in VS.NET and then perform the following in my Form's code

    private Icon myIcon
    ...
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
    myIcon = ((System.Drawing.Icon)(resources.GetObject("icon1.ico")));
    ...

    myIcon however is always null It's a simple matter I'm sure but I'm brain dead at the moment. How can I make sure that I have a valid icon instance in this case? Regards Senkwe Just another wannabe code junky

    P 1 Reply Last reply
    0
    • S Senkwe Chanda

      Hi guys, I'm trying to draw an icon onto the surface of a form. What I do is create the icon in the bitmap editor in VS.NET and then perform the following in my Form's code

      private Icon myIcon
      ...
      System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
      myIcon = ((System.Drawing.Icon)(resources.GetObject("icon1.ico")));
      ...

      myIcon however is always null It's a simple matter I'm sure but I'm brain dead at the moment. How can I make sure that I have a valid icon instance in this case? Regards Senkwe Just another wannabe code junky

      P Offline
      P Offline
      Peter Stephens
      wrote on last edited by
      #2

      Just looking at form designer generated code I get this:

      this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

      I seems like it gets the icon out of the associated resx file. -- Peter Stephens

      S 1 Reply Last reply
      0
      • P Peter Stephens

        Just looking at form designer generated code I get this:

        this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

        I seems like it gets the icon out of the associated resx file. -- Peter Stephens

        S Offline
        S Offline
        Senkwe Chanda
        wrote on last edited by
        #3

        Thans, I'll give that a try Regards Senkwe Just another wannabe code junky

        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