The Collapsible Panel Control

The last control you'll consider is a Windows XP standby that's finally available in the .NET world. It's a CollapsiblePanel developed by Microsoft and designed to mimic the Windows XP common task pane, which is shown on the side of many standard windows (see Figure 12-7).

Figure 12-7. The common task pane in Windows XP

This panel has several noteworthy features:

• It supports Windows XP themes, giving it a slick look with a detailed gradient background.

• It supports collapsing. When you click the arrow button in the top-right corner, the panel is reduced to just its header. You can click the arrow button again to expand the panel. In Figure 12-7, the Other Places panel is collapsed.

The .NET version of the collapsible panel duplicates this functionality (see Figure 12-8).

Figure 12-8. The .NET CollapsiblePanel, expanded (left) and collapsed (right)

The CollapsiblePanel is particularly useful when generating dynamic interfaces. For example, you can stack multiple CollapsiblePanel controls one on top of the other, and dock them all to the top of the form. This ensures that as one panel collapses, all the panels underneath shift up. To get even fancier, you can put CollapsiblePanel controls in the FlowLayoutPanel (discussed in Chapter 21). Then set the FlowLayoutPanel.Margin property to add a basic amount of space between each CollapsiblePanel, and set the FlowLayoutPanel.Padding property to add some space between the FlowLayoutPanel borders and the CollapsiblePanel controls inside. With this approach, you can duplicate the look of the Windows XP common tasks pane (see Figure 12-9).

Flowlayoutpanel Resize Controls
Figure 12-9. Dynamic interfaces with the CollapsiblePanel

Although the code for the CollapsiblePanel is too long to repeat in its entirety (download the full code with the sample content for this book), it's fairly easy to pick out the important details using the concepts that you've explored in this chapter.

+3 0

Post a comment