Understanding .NET Visual Inheritance
The .NET Visual Inheritance is nothing but the ability of making other forms using the .NET forms and components as base classes. The working nature of the inheritance for forms and controls is very similar to any of the .NET objects working and hence it will be easy for you to use Visual Inheritance in your applications if you are thorough in the working concepts of inheritance. You can make available many of the basic functionality in your application using visual inheritance.
In the first instance you have to complete all your base coding pertaining to your base form. Then instead of copying or re-writing codes or call methods for changing the properties of global functions, you can simply use form inheritance for making available your base forms functionality in your new form also.
The base form can be inherited into the new form from where you need to implement the functionality and after the inheritance the base forms public and protected functionality will get merged into the new form or the child form.
For example, if you want to have a navigation panel in your application that can assist in navigating between records then you have to develop the codes for the navigation functionality in your base form and get it inherited into the child form to get the same navigational functionality in the child form also. The process of such inheritance is known as Visual inheritance and it is also popularly known as Form Inheritance in certain quarters.
Form Inheritance can be made use whenever there is a need for providing functionality to status bars, info labels, navigational panels, etc., in your applications or project. Once you complete the coding part for the required functionality in your base form, you can inherit the base form into the child form or the form from where you would like to provide similar functionality. Further, it is also possible for you to override in the child form few or all of the base form functionality without affecting the base form at all.
The syntax used for inheritance between forms is very similar to the syntax that has been used for inheritance between classes. The keyword Inherits is used in VB.NET for inheriting a form and where as the colon operator (:) is used to inherit a form in C#.
A sample code for both the VB.NET and C# to create a ChildForm form that inherits from the ParentForm is given below:
You can also use Inherited User Control or Inherited Form for inheriting a form in your Visual Studio.NET project.
If you want to build and use form templates that can contain common GUI elements in all your forms of the application, then for the purpose you can make use visual inheritance to accomplish the task. For Instance, if all your forms are to be made to display the company logo and a help button, then all the requirements can be written in a base form and the base form can be derived into the new form.
Visual Inheritance can also be made use to alter any of the behaviour or the appearance of a form based on the users needs and requirements and the purpose for which the form is used.
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage