JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page


There is no more popular control in Visual Basic than buttons, with the possible exception of text boxes. Buttons are the plain controls that you simply click and release, the buttons you see everywhere in Visual Basic applications-usually just rounded rectangular, gray buttons with a caption, as you see in the Buttons example on the CD-ROM and which you will see at work in Figure 6.1.

Figure 6.1: A button at work.

Buttons provide the most popular way of creating and handling an event in your code-every Visual Basic programmer is familiar with the button Click event. Buttons can be clicked with the mouse or with the Enter key if the button has the focus.

Besides using buttons in forms directly, they're very popular in dialog boxes. As we've seen in Chapter 4, you can set the AcceptButton or CancelButton property of a form to let users click a button by pressing the Enter or Esc keys-even if the button does not have focus. And when you display a form using the ShowDialog method, you can use the DialogResult property of a button to specify the return value of ShowDialog.

You also can change the button's appearance, giving it an image or aligning text and images in it as you like. You can evem-make it look flat for a "Web" look, setting the FlatStyle property to FlatStyle.Flat. Or, you can set the FlatStyle property to FlatStyle.Popup, which means it looks flat until the mouse pointer passes over it, when the button pops up to give it the standard Windows button appearance.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor