Showing posts with label Icon. Show all posts
Showing posts with label Icon. Show all posts

Wednesday, July 30, 2008

Setting the Form Icon to an Application Resource in VB.NET

I have an application with a main form and many dialogs. I want the main form and all of the dialogs to use the same icon in the forms' title bars. So, instead of defining the Icon property on each form, I have created an application resource and added a line of code to each Form_Load method.

First, add an Icon to your Project Resources (Project/Properties then on the Resource tab). Remember the name of the icon resource you create. Mine is AppIcon in this example.

Then for each Form_Load method in the VB.NET app (for the main form and each dialog's form), I add the following:

Me.Icon = My.Resources.AppIcon

There may be even better ways to do this, but this is the simplest I have found so far.

For more information on using resources, see:

http://visualbasic.about.com/od/usingvbnet/a/ResVBNET.htm