CONTROLS AND COMPONENTS

Controls are graphic by nature. Buttons, text boxes, and labels provide graphical input and feedback for the user. They display data and let the user trigger program actions. Some controls (such as grid controls, tree view controls, and calendar controls) are quite powerful and provide a rich variety of tools for interacting with the user.

In contrast, components are represented by graphical icons at design time and are hidden at run time. They may display some other object (such as a dialog box, menu, or graphical indicator), but the component itself is hidden from the user.

Many components display information to the user. Others provide information needed by graphical controls. For example, a program can use connection, data adapter, and data set components to define data that should be selected from a database. Then a Grid control can display the data to the user. Because the connection, data adapter, and data set objects are components, you can define their properties at design time without writing code.

Figure 8-1 shows a form at design time that contains several components. The components appear in the component tray at the bottom of the form, not on the form’s graphical surface.

FIGURE 8-1: At design time components appear in the component tray below a form.

image

This example contains four components. Timer1 fires an event periodically so the program can take some action at specified time intervals. ErrorProvider1 displays an error icon and error messages for certain controls on the form such as TextBoxes. BackgroundWorker1 performs tasks asynchronously while the main program works independently. ImageList1 contains a series of images for use by another control such as a Button, ListView, or TreeView.

Aside from the lack of a graphical component on the form, working with components is very similar to working with controls. You use the Properties window to set a component’s properties, the code editor to define its event handlers, and code to call its methods. The rest of this chapter focuses on controls, but the same concepts apply just as well to components.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.138.97