This comes from: InfoPath Team Blog
InfoPath doesn't have a built-in Tab Control, but it's easy enough to build one using tables, buttons, and views, so let's do it!
InfoPath doesn't have a built-in Tab Control, but it's easy enough to build one using tables, buttons, and views, so let's do it!
The basic idea
Here's what to build:
- Views for the contents of each tab
- Table with shading to give the visual effect of tabs
- Buttons for each tab with a rule that switches the view
For example:
Then when the user clicks "Details" they switch views to see this:
How To, with tricks along the way
- Create all of your views (from the Views task pane)
- Select the same color scheme for each view (use the Color Schemes task pane)
- Use Background Color on the Format menu to make the background of each view the second color for the current color scheme (the second-darkest color at the top of the color picker)
-
- Insert a layout table (on the Insert menu, click Table)
- Make it two rows high. The first row will be for the buttons, the second will be for the tab content.
- Split the first row to make a cell for each view, plus one extra cell to take the remaining horizontal space.
-
- Insert a button into each cell (from the Controls task pane)
- Add a rule to each button to switch to the corresponding view. Do this even for the current view's button.
- Make the current "active" button Bold, so it stands out.
-
- Use borders and shading (on the Format menu)
- Select all the buttons at once (hold down the Control key and click each one), then remove all borders and shading from the buttons (they're invisible except for their label!).
- Select the entire table, then add borders inside and out using the first color in the color scheme (the darkest color).
- Select the non-active cells and set their shading to the third lightest color of the color scheme.
- Select the active cell and the content cell, and set their shading to white.
- Select the active cell and remove the bottom border so it becomes connected to the content cell.
- Select the right-most "extra" cell and remove the top and right border
-
- Copy the table to each view
- Update the borders and shading to change the "active" cell for each view
- Put all your fields for each tab in its content cell
-
Getting fancy
If the tabs above aren't pretty enough for your form, add some images inside a few more table cells around each button to provide rounded corners and other visual effects. It's more work, and requires some image editing, but with a little elbow grease you could get something as schmancy as this:
Very clever. Thanks for the tip!
ReplyDeleteSuperb !!!
ReplyDeleteCan you put more light on including images?
Hi,
ReplyDeleteWhen open a form with multiple views, can it stay at the same view when it was created? it seems to display the default view regardless when the form was last saved...
Thanks
I guess it would be something along the lines of enabling the user to save the last open view state of the form - a bit of custom code could potentially acheive this?
ReplyDeleteThis could be a solution: http://www.infopathdev.com/forums/t/7554.aspx
ReplyDeleteVery nice post ... thank you!
ReplyDeleteThis can be achived even without using the Views,
ReplyDeleteStep 1 - Create a Table as explained above with two rows. Additionally keep one hidden text box.
Step 2 - In the second Row add three sections and your controls inside these section.
Step 3 - On click of those buttons set the hidden text with one value.
step 4 - in all the Sections added in the second row, add the conditional formation based on the hidden value, and show only required section
Exactly what my manager asked me do! I have been looking for a solution.
ReplyDelete