Browse DevX
Sign up for e-mail newsletters from DevX


Give Your Forms a Base

A base form class makes it easy for you to give your users a consistent experience without needing to write a lot of user interface code.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

reat Windows applications have a consistent user interface. As users learn how to work with one form in the application, they can leverage that knowledge to work with other forms in the application. This both minimizes the requirements for end-user training and support and maximizes end-user satisfaction. You can achieve a consistent feel throughout your user interface by building your own base form class. In this base form class you can write the code for all of the standard user interaction features. Every form in the application that inherits from your base form class will automatically support any feature defined in the base form class.

Creating the Base Form Class
You create a base form class the same way you create any form in a Windows application; just add a new form to a Windows Application project. Giving the base form class a clear name, such as eOrderOnLineWinBase, will help you keep track of the base form class. You may or may not want to add controls to this base form class. If there are common UI elements on many of the forms of your application, such as a particular icon or set of buttons, then it is useful to add these to the base form class. Common UI elements in the base form class then appear on every form that inherits from the base form class, a technique referred to as visual inheritance. Frequently, however, you may find that your forms don't have common UI elements, so it is not desirable to add common controls in fixed positions to your base form class.

You should add event handlers to the base form class to handle form and control events consistently on any form that inherits from the base form class. By leveraging the code in the base form, you minimize the amount of repetitive code in the forms.

Add event handlers to the base form class to handle form and control events consistently on any form that inherits from the base form class.
For example, to give the user a visual indicator of the control that has focus, you can change the background color of the active control on the form. To be consistent, every form should incorporate the same technique. You could add the code to handle the Enter and Leave events of every control to every form in your application; but this could require a significant amount of code since a Windows application of any significant size can require 50 or more forms. It makes more sense to write this code one time and then reuse it from every form in your application.

Thanks for your registration, follow us on our social networks to keep up-to-date