Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

draw an icon on the form from resources

Posted on 2010-09-24
2
379 Views
Last Modified: 2012-05-10
Hi there, i am trying to retrieve an icon from my resources in order to draw it via GDI...

SO here is what i do and i keep getting null

my resource's name is tram and the icon is tram.ico


Dim list = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames()

Dim assembly As System.Reflection.Assembly =Me.GetType().Assembly

Me.theIcon = GetEmbeddedIcon(assembly.GetName().Name & ".tram.ico")

Form1.gMyGraphics.DrawIcon(theIcon, 20, 20)



Function GetListOfEmbeddedResources() As Array
        Return _
         System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames
    End Function
    Function GetEmbeddedIcon(ByVal strName As String) As Icon
        Return New Icon(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strName))
    End Function

Open in new window

0
Comment
Question by:ioustinos_sarris
2 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 33754368
There is a trick actually in the constructor of the Icon class you can specify the name of the resource. See code block.
Make sure that you right clicked on the resource in the solution explorer and have set the "Build Action" property to "Embedded Resource"

Dim ico As New Icon(GetType(Form1), "blankcd.ico")
Me.Icon = ico

Open in new window

0
 
LVL 7

Accepted Solution

by:
klakkas earned 500 total points
ID: 33754369
Hi.

Why not just go with my.Resources.Tram?
This will return the image you want, ready to be drawn by GDI...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question