Chapter 11 examined the Form class, the central unit of programming a rich client application with Microsoft Visual C# .NET. This chapter introduces many of the basic controls that are used with Windows Forms, including buttons, list boxes, combo boxes, and labels, as well as the event handling mechanism used by controls to pass notifications to their parents. This chapter also covers containment, which allows specific controls, such as group box and panel controls, to contain other controls.
The classes in the System.Windows.Forms namespace provide a new way to develop forms-based applications for Windows. When I first started programming for the Windows platform, I had to write large amounts of code to route and handle messages sent from the operating system to control the application. Any error in the message routing code would break the application and lead to hours, if not days, of debugging. Copious amounts of C code were required to change even the simplest of control attributes. For example, creating a push button control with a specific color required hundreds of lines of code.
Windows Forms change all of that. With Windows Forms and the .NET Framework, building a rich client application is greatly simplified. You can build applications that are far richer than ever before, while writing less code. In fact, one of the great things about the Windows Forms Designer is how little code you actually need to write. All properties are exposed through the Properties window, enabling you to define the appearance and behavior of controls declaratively, rather than requiring you to write code. By reducing the amount of code you must write, Visual C# .NET and Windows Forms enable you to concentrate on what really counts—adding real functionality to your application.