How to hide a control and its label on an InfoPath form

Learn how you can hide a control and the text that is displayed in front of the control on an InfoPath form thereby eliminating empty vertical spaces between labels and controls on two rows of a custom table.

ADVERTISEMENTS

Labels are pieces of text that describe or give a title to a particular control.

When you drag-and-drop a field onto the view of an InfoPath form template, a label may automatically appear if InfoPath is configured to automatically create labels. You can also manually add a piece of text in front of a control if you want to create a label.

You can use conditional formatting in InfoPath to hide controls. However, when you add text for a label or when a label is automatically created, you cannot apply conditional formatting to the text, to be able to hide it, if you want to hide the control and the label that belongs to it. So you would have to also use a control for the label to be able to hide it.

You can use a Text Box control, make it read-only, and remove its borders to create a label. But doing so would force you to create a field in the Main data source of the form.

If you do not want to create a field in the Main data source of a form, but still want to be able to use a control so that you can apply conditional formatting to it to hide it, you can use a Calculated Value control to do so. But you must add the calculated value control in a certain way to the form template for InfoPath not to force you to bind it to a particular field.

To use an unbound calculated value control as a label:

  1. In InfoPath, click Calculated Value on the Controls task pane or in the Controls list on the Home tab to add the control to the view of the form template.
  2. On the Insert Calculated Value dialog box, enter the text for the label in the XPath text box. When you enter the text, ensure that you place double-quotes around the text, and then click OK.

Now you can apply conditional formatting to both the label displayed via the calculated value control as well as the control it belongs to be able to hide both the label and the control.

For a full demonstration of how you can create an InfoPath form on which a control and its label can be hidden, watch the InfoPath 2013 video tutorial below.

 


Related Posts

 

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services