OBJECTIVES
This chapter covers the following Microsoft-specified objectives for the “Creating User Services” section of Exam 70-316, “Developing and Implementing Windows-Based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET”:
Create a Windows form by using the Windows Forms Designer:
Add and set properties on a Windows form.
Create a Windows form by using visual inheritance.
Build graphical interface elements by using the System.Drawing namespace.
Windows forms are the basic user interface element of a Windows application. The exam objectives addressed in this chapter cover the basics of designing a Windows form by using the Windows Forms Designer. This exam objective addresses the following specific topics:
How to create a Windows form and change its behavior and appearance through its built-in properties and through custom-added properties.
How to use visual inheritance to rapidly design a Windows form by inheriting it from an existing Windows form.
How to build various graphical interface elements by using the System.Drawing namespace.
Create, implement, and handle events.
Event handling is the core part of programming a user interface. This chapter describes how to make a Windows form respond to user actions. You'll find further coverage of this exam objective in Chapter 4, “Creating and Managing .NET Components and Assemblies.”
OUTLINE
An Overview of the .NET Framework 25
An Overview of the Development Tools 27
Understanding Classes, Inheritance, and Namespaces 29
Creating a Windows Forms Application 32
Using the System.Windows.Forms.Form Class 33
Designing a Windows Form by Using the Windows Forms Designer 34
Exploring the Generated Code 37
Setting and Adding Properties to a Windows Form Windows Form 48
Using the Visual Designer to Set Windows Form Properties 48
Handling Events by Attaching a Delegate 65
Handling Events by Overriding a Protected Method of a Base Class 71
Building Graphical Interface Elements by Using the System.Drawing Namespace by Using the System.Drawing Namespace 76
Understanding the Graphics Objects 77
STUDY STRATEGIES
Make yourself comfortable with the major properties of Windows forms. This chapter's examples and exercises introduce the most important form properties.
Invest time looking at and understanding the code that is automatically generated by Visual Studio .NET for you.
Make sure you fully understand event handling. This will enable you to write interactive Windows applications.
Experiment with classes in the System.Drawing namespace. In addition to the completing the examples and exercises in this chapter, it would be a good idea for you to create a small sample program to test the behavior of a class or a property whenever you are in doubt.
If you are new to object-oriented programming, consider reading all or some of the recommended material listed in the “Suggested Readings and Resources” section at the end of this chapter.
18.119.123.252