The BasicsEnabling a caption on a control or indicator is straightforward enough, right-click the control in the front panel > Visible Items > Caption.
At first, the control doesn't appear to change if you leave the caption as its default value:
To make sure the control displays the caption information rather than the default label, verify that the label has been turned off for visible items.
In the Context Help window, any control with its caption showing (assuming the caption is different than the label) will display the caption at the top, and the label in brackets underneath. Hover over the terminal of a subVI, you'll see the caption of the control/indicator in the tip strip instead of the label. Use CasesThere are two possible reasons for wanting to show the caption:
- Long caption, short label - If you want your control/indicator to have a long, meaningful description on the panel, but you don't want that long string getting in the way of the diagram, you could show its caption.
- Localization - This is the primary reason to use captions in LabVIEW. When localizing LabVIEW into other languages, you don't want to change the labels of controls and indicators; And potentially break code that programmatically refers to controls and indicators by name. Instead, you show localized captions (and hide the labels) for the controls and indicators in all user-facing VIs that ship with LabVIEW.
Deleting a CaptionIn older LabVIEW versions, there was no easy way to delete the caption of a control/indicator. Thankfully, in LabVIEW 8.2 and later, it is very easy. All you need to do is select the caption with your selection tool and press the Delete key on your keyboard. Note that this is not the same as highlighting the text in the caption and pressing the Delete key; If you do that, the control will still have a caption, but it will be an empty string. Working with Captions ProgrammaticallyBy default, controls and indicators do not have captions. If you try to read the Caption.Text property of a control like this:
One of three
different things can happen with this code:
- If the control already has a caption, you'll get the caption text.
- If the control doesn't already have a caption, and the VI that owns the control is in edit mode, then a caption will be created for you, with the same string as the label, and you'll get that text.
- If the control doesn't already have a caption, and the VI that owns the control is in run mode, then you'll get error 1320, which tells you that you can't read properties of control parts that haven't been created yet when the VI is in run mode.
There is another helpful VI Server property that you can use. The HasCaption property will tell you if a control even has a caption, to begin with before you start trying to do other caption-related actions/tasks:
One last helpful method if you want to delete a caption programmatically, it's with a direct block to delete the value of a caption in the property node as shown in the image below: