Adding great features to form's system menu via Inheritance

Applies To

OS:
VB:
Windows
.NET Framework

Download the project, including the source (126 kb)

Sometimes a certain piece of code is so general that you want to bottle it and sell it to everyone. In this case we have a piece of code that I normally apply to all the forms that I create in VS.NET. I figure that every form can use a built-in ability to do the following:

So how do you apply this code to your forms? That's the cool part and this is what makes inheritance so powerful. Here is a short step by step tutorial (it assumes you have downloaded the project).

  1. In your project, add FormSysMenuValueAdd.dll to your references. You'll find it in Library/bin folder
  2. Now put your form into View Code mode and scroll to the very top. There you will see code like this:
     
    		Public Class Form1
    		    Inherits System.Windows.Forms.Form		
    	
    Change it to the following:
     
    		Public Class Form1
    		    Inherits FormSysMenuValueAdd.MasterForm		
    	
Yep, that's it. When you run your now, it will have all the extra features sitting in the system menu.
Note: I can't take credit for the screenshot code, I downloaded it somewhere, I don't know where.

Download the project, including the source (126 kb)