2014/04/19

Changing icons of Desktop Application using Inheritance

Programming Language: C#

Tired of putting icon across many forms?


When you’re dealing with Windows form applications, usually we manually configure our forms and locate for the icon. Well, when you will be using the same logo for your application over and over again, you don’t have to deal and look for those logos within the computer time and again. With today’s lesson, I’m gonna teach you to make your work more fast and efficient with the use of “Inheritance”.   To start with, you need the following:
  • Basic knowledge of C#.net
  • Basic knowledge of OOP(Object-Oriented Programming)
  • Visual Studio / Mono / SharpDevelop
Step 1: Create a project

Create a project named “SampleInheritLogo”. After creating the project, you’ll be automatically provided with Form1.cs. Leave it be in the meantime.

Step 2: Create another Windows form
Create another Windows Form named “logo.cs”. Name it this way so that you will not use it for other purposes aside from inheriting it.

If you’re a beginner, you can change the logo or icon here. Pick an icon what’s best for your application. I recommend creating your own icon at: http://www.favicon.cc/
Step 3: Go to Form1.cs. Change the inheritance to your own form.
Change the inheritance Form1 : Form into Form1 : logo. Notice that it will appear now within the intellisense so there’s no need to type it manually. 

**note: you should first Build your application before applying Step 3 to avoid errors within your form and to recognize your inherited form you made which is logo.cs.
And now your form should look like this now. This is the result of your form inheriting fromlogo.cs which has an icon we modified a while ago. Don’t worry about the controls within your application, it will only change the icon not the whole control itself. Unless, if you added some controls within it, then you also inherited it.

No comments: