Topics in This Chapter: Show
The previous chapter introduced the Control class and the methods, properties, and events it defines for all controls. This chapter moves beyond that to examine the specific features of individual controls. It begins with a survey of the more important .NET controls, before taking an in-depth look at how to implement controls such as the TextBox, ListBox, TreeView, and ListView. Also included is a discussion of the .NET drag-and-drop features that are used to move or copy data from one control to another. Windows Forms (WinForms) are not restricted to using the standard built-in controls. Custom GUI controls can be created by extending an existing control, building a totally new control, or fashioning a user control from a set of related widgets. Examples illustrate how to extend a control and construct a user control. The chapter concludes with a look at resource files and how they are used to create GUI applications that support users from multiple countries and cultures. 7.1 A Survey of .NET Windows Forms ControlsThe System.Windows.Forms namespace contains a large family of controls that add both form and function to a Windows-based user interface. Each control inherits a common set of members from the Control class. To these, it adds the methods, properties, and events that give the control its own distinctive behavior and appearance. Figure 7-1: Windows Forms control hierarchy Figure 7-1 shows the inheritance hierarchy of the Windows Forms controls. The controls marked by an asterisk (*) exist primarily to provide backward compatibility between .NET 2.0 and .NET 1.x. Specifically, the DataGrid has been superseded by the DataGridView, the StatusBar by the StatusStrip, and the ToolBar by the ToolStrip. Table 7-1 provides a summary of the more frequently used controls in this hierarchy. Table 7-1: Selected Windows Forms Controls
This chapter lacks the space to provide a detailed look at each control. Instead, it takes a selective approach that attempts to provide a flavor of the controls and feaures that most benefit the GUI developer. Notable omissions are the DataGridView control, which is included in the discussion of data binding in Chapter 12, “Data Binding with Windows Forms Controls,” and the menu controls that were discussed in Chapter 6, “Building Windows Forms Applications.” Which section of a report appears at the top of the first printed page?Page Header This section is printed at the top of every page. For example, use a page header to repeat the report title on every page. Group Header This section is printed at the beginning of each new group of records. Use the group header to print the group name.
What property determines where the background picture for a form displays on the form?Glossary. Which control allows you to type an entry or choose an entry from a list?Use a combo box to enable a user to either type an entry or choose only one item from the list. The control displays the current value in the text box, regardless of how that value is entered.
Which two properties control how a form and subform are linked?The subform is linked based on their LinkMasterFields and LinkChildFields properties, and appear on the subform's property sheet as "Link Master Fields" and "Link Child Fields".
|