Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
Bing
BizTalk
Book Excerpts
Build and Deploy
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
Internet Explorer 8.0
Interviews
iPhone
Iron Ruby
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
Network
NHibernate
Object Oriented Development
Odata
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Python
Q&A
Rails
Rake
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



INSTANTLY dtSearch® TERABYTES OF TEXT


 


INSTANTLY dtSearch® TERABYTES OF TEXT

Reader rating:
Click here to read 9 comments about this article.
Article source: CoDe (2004 - March/April)


Article Pages:  1  2 3 - Next >


Give Your Forms a Base

Create a base form class to ensure that all of the forms in your application behave consistently. This technique minimizes the amount of repetitive code you need to write to manage the user's interaction with your forms.

Great Windows applications have a consistent user interface. As the user learns how to work with one form in the application, the user can leverage that knowledge as they work with other forms in the application. This minimizes the requirements for end-user training and support and maximizes end-user satisfaction.

"
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.
"

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.

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.

&

By: Deborah Kurata

Deborah Kurata is cofounder of InStep Technologies Inc., a professional consulting firm that focuses on turning your business vision into reality using Microsoft .NET technologies. She has over 15 years of experience in architecting, designing and developing successful applications.

Deborah is the author of several books, including Best Kept Secrets in .NET (Apress), Doing Objects in Visual Basic 6.0 (SAMS) and Doing Web Development: Client-Side Techniques (Apress). She is on the INETA Speaker’s Bureau, is a well-known speaker at technical conferences, and is a Microsoft Most Valuable Professional (MVP). After a hard day of coding and taking care of her family, Deborah enjoys blowing stuff up (on her XBox of course).

Some of the information in this article was obtained from her upcoming book, Doing Objects in VB 2005.

deborahk@insteptech.com

Fast Facts

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.



Article Pages:  1  2 3 - Next Page: 'Defining the Event Handlers' >>

Page 1: Give Your Forms a Base
Page 2: Defining the Event Handlers
Page 3: Defining the Event Handlers (cont.)

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
2.5 out of 5

123 people have rated this article.

      CODE TRAINING

 

CODE TRAINING