Setting Application Icon using code

G

Guest

I have a shared project that contains icons and bitmaps that are used
throughout my suite of applications.

I have to set Form.Icon, PictureBox.Image, etc. using code because the form
designer can't see the icons and bitmaps unless they're in the local project.
This is only slightly inconvenient compared to the benefits from managing the
icons and bitmaps centrally.

However, I can't see how to do set the Application Icon using code. It seems
the only way to set Application Icon is to have the icon in the local project
and to set it via the project's property pages. Is there another way?
 
K

Kevin Yu [MSFT]

Hi,

To set the icons for forms, we can use Form.Icon = new
Icon("filename.ico"); to achieve this. However, the application icon is set
at link time. When building, the linker gets everything including the
application icon file and generates the target assembly. This job cannot be
done at runtime. So, we cannot set the application icon at runtime using
code.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top