Form Templates

Any application would be required to define a standard representation and user interface for its users. This is true for both Web and Windows applications. Developers use a variety of techniques to standardize their applications and to give a common look and feel to their applications.

 

We get the following advantages by using Form Templates

  • Create portions of the form (Web and Windows) and reuse them across multiple forms
  • Ability to create multiple templates if necessary, which can be reused.
  • Ability to change the template whenever required.

 

Let’s look at one of the methods, which consist of two steps.

  • Creating a master form (Windows forms or Web Forms)
  •  The rest of the application forms inherit from this form instead of System.Windows.Forms.Form or System.Web.UI.Page.

 

To demonstrate the above, we’ll create a windows application. This application has two forms. One is the master form and the second inherits from it.

 

Shown below is the figure of the master form. We have changed the form icon, resized it, and added an image to it. As can be seen, the title of the form is “Form1”.

 

 

We can have all this properties of Form1 in Form2 by simply inheriting from Form1. Given below is the line of code in VB.NET.

 

Public Class Form2

    Inherits Test.Form1

 

We inherit Test.Form1 instead of System.Windows.Forms.Form

 

Shown below is the Form2

 

All properties of the Form1 are inherited by Form2. A small arrow is shown on the picture box control, which means, it is an inherited control, which makes it Private, and its properties can’t be changed here.

 

It is therefore advisable to create form templates in every project whether it is web or a windows application.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish