Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Collapsible Sections

Collapsible Sections

  • Comments 6

Collapsible Sections

 

Mark asks:

 

How do I create a collapsible section? That is, a section that can show/hide child controls, whether they are required or not. I can't use an optional section, because it requires binding.

 

The easiest way to do this is to this is using Conditional Formatting. Select the Section control, then pick Format | Conditional Formatting.... Add a rule where the formatting is “Hide this control”.

 

Adding conditional visibility to a section

 

We often call this “conditional visibility.” Like everything in InfoPath, the view state is driven entirely by the data, so you need something in your data which maps to the expand/collapse state. One common approach is to add an attribute field to the group element the section is bound to. It shows up in your data when saved, and the expand/collapse state is saved when users save the form.

 

Designing a collapsible section

 

Bind a checkbox to the attribute, and you now have UI which lets the user control the state. If you prefer a button, you can create a rule which sets the value of the attribute; use two buttons with more conditional visibility rules to swap the label (e.g. between a + and a – to look like a TreeView). You can also write code which modifies the value of the attribute, and the section will show or hide.

 

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
Page 1 of 1 (6 items)