Label controls are used to display static text to the user. By static, I mean that the user can't change the text directly (but you can change the text with code). Label controls are one of the most commonly used controls, and, fortunately, they're also one of the easiest. Labels are most often used to provide descriptive text for other controls, such as text boxes. Labels are also great for providing status-type information to a user, as well as for providing general instructions on a form. You're going to build on the Picture Viewer project from Hour 6, "Building FormsAdvanced Techniques," for most of this hour. Although you'll be adding the controls to the interface, you won't be making them functional until you progress into the chapters on writing code. Start by following these steps:
Notice how the label resized automatically to fit your text. This is a new feature to Visual C# 2005. To create a multiline label, you would click in the Text property to display a drop-down arrow and then click the arrow to access a text entry box. You could then enter text and separate the lines by pressing Enter. In most cases, it's best to place label text on a single line, but it's nice to have the option. Another interesting aspect of the label control is that a label can have an associated hot-key. A hotkey appears as an underlined character in the label's text, as in First Name:. When the user presses the Alt key in conjunction with the hot-key (Alt+F in this example), the focus is moved to the next control in the tab order after the label. To assign a hot-key to a label, you preface the hot-key in the label's Text property with an ampersand (&). For example, to create the F hot-key for the First Name label, you would enter the following into the Text property of the label: &First Name:. |