Solved

draw an icon on the form from resources

Posted on 2010-09-24
2
373 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now