VB.net Label Control

Source: Internet
Author: User

Label (label) controls are used to display text, which is one of the controls that are often used to design the application interface, mainly to display other control names, to describe the program's running status or to identify the results of the program's running, and so on, to respond to events in the program or to track the results The icon for the Label control in the Toolbox is as shown in the figure:

There are many situations in which a label control is used, but the information displayed with a label control is generally not an attribute that describes the label control itself, but rather a description of the properties or characteristics of other controls, such as names. For example, you can use a Label control to add descriptive information to a control such as a text box (textbox), list box (ListBox), combo box (ComboBox), and so on.
You can also write code that changes the text content displayed by a label control to respond to event or state information when the program is running. If a program is running, some objects change with different time periods, and then the label control can be used to process the status message.
Note: The label control does not accept focus
1. Set the text of the label
Displays text in a Label control, using the "text" property. When you develop your application, you first select the Label control, select Properties window, and then set the property to a string amount in the Properties window.
The maximum length of the "Text" property can be set to 1024 bytes.
2. Set the text properties in the label
Text in a Label control defaults to the left (from the left to the right), by setting the "TextAlign" property can change the arrangement, set "TextAlign" as "right", arranged in the right-hand, set "TextAlign" as " Center, arranged in a centered manner.
3. Other properties of the label
The property that describes the border of a label control is BorderStyle, and if you set the BorderStyle property to FixedSingle (which can be done at design time), the label control has a border; If you set the BorderStyle property to Fixed3D , the label control has a solid border that looks like a textbox (text box). You can also change the other appearance of a label control by setting properties such as the BackColor (background color), ForeColor (font color), and font (fonts) of the label control.
4. Create an access key with a label
You can define the character in the Text property as an access key, and you want to define the text property of the label control as an access key, you first set the UseMnemonic property to True. After you define the access key for the label control, the user presses the [ALT + specified character] key combination to press the focus [ TAB key order to the next control. Add a hyphen (&) before the letter that is the access key to create an access key for other controls that do not have a caption, such as a TextBox control. As mentioned above, the label does not accept the focus, so the focus is automatically moved to the next control in the [tab] key order. You can use this technique to specify access keys for text boxes, picture frames, combo boxes, list boxes, drive list boxes, directory list boxes, networks, and images. To specify the label as the access key for the control, perform the following steps:
(1) Draw the label first and then draw the control. or draw the control in any order and set the label's TabIndex property to the control's TabIndex property minus 1.
(2) Specify an access key for the label in the label's Text property with a hyphen.
Note: Sometimes you might want to display hyphens in label controls instead of creating their access keys. If the data contains hyphens in a single Recordset, and the label control is bound to a field in the Recordset, the situation appears. To display hyphens in a label TextBox control, set the UseMnemonic property to False.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.