Solved

Reference to Icon Files

Posted on 2006-11-16
6
199 Views
Last Modified: 2010-04-23
I am trying to use the same icon in all forms of a VB.NET, as well as in installation shortcuts.  I can go through one form at a time and assign an incon file to each.  

The results are erratic.  Sometimes VB insists on copying or moving the icon file to a different directory.  For example, if the icon file is stored in the project/bin directory it will automatically move it to the project/ directory.   Then if I reasign the forms to the moved file, it later gets deleted or removed again.  Then it wont compile because it cant find the icon file.

I tried assigning the icon file as a project resource but the behaviour is still erratic.

Is there a way to assign the icon file to each form within the code?

Also, in general, when I get an complation error message about an invalid reference - cant find file etc....  How do I find out where in my project that invalid reference is located so that I can fix it?

Bill
0
Comment
Question by:BW999
6 Comments
 
LVL 13

Accepted Solution

by:
newyuppie earned 168 total points
ID: 17957164
why dont you place the icon in the application resources, set it's embedded property to TRUE. then to modify the form icon by code would be something like

Me.Icon = New Icon(My.Resources.MyIcon, My.Resources.MyIcon.Size)

in the New or Load event.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 166 total points
ID: 17957233
Hi BW999,

Create a form with no code in it, set this form's Icon property to what you want and inherits every form of your application from this base form.

If you ever need to change the icon, go back to this base form, change it and recompile.

Cheers!
0
 
LVL 14

Assisted Solution

by:jake072
jake072 earned 166 total points
ID: 17965687
Or having a combination of both solutions would work well as well.  You can have the embedded resource, and inherit the form.  (Personally, this is what I have done in some of my own projects -Add the resource and inherit the form that is).

Jake
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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