Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Exploring New WinForm Controls in VS .NET Whidbey : Page 5

Catering to the strength of the third-party .NET component market and the power of the .NET Framework itself, Microsoft includes several powerful new WinForm controls in the Base Class Libraries for Windows application development.


advertisement
New Container Controls
Figure 7. The SplitContainer Class: This class simplifies the common task of combining Panel controls with a Splitter to achieve a segmented container.
Whidbey includes several new controls that provide advanced layout services. Three new container controls are provided to you to simplify three different control layout scenarios: SplitContainer, FlowLayoutPanel, and TableLayoutPanel. Simplifying Form Design
The SplitContainer control, shown in Figure 7, combines several controls and docking settings commonly used in a single composite control, saving many steps in the development of complex forms. A common task in designing forms is to use controls that could share a vertical or horizontal space. The existing Splitter control allows an application user to adjust the division of space separating sections of a container control, such as a Panel class. Use the SplitContainer control to eliminate the need to perform these combined steps multiple times.

The SplitContainer class provides several properties to modify the behavior of an instance of the control. Use the FixedPanel property to select which panel in the control should not resize as the SplitContainer instance resizes. Set the SplitterDistance and Orientation properties to control the direction and starting location of the splitter bar. The Panel1MinSize and Panel2MinSize properties are used to specify the minimum size of the SplitterPanel instances in the SplitContainer, effectively controlling how close the splitter bar can be placed to either edge of the control. Reducing Control Layout Code

Figure 8. The FlowLayoutPanel and TableLayoutPanel: These classes provide a combination of container control and positional layout services while differing on the positional logic implemented.
Two closely related controls, the FlowLayoutPanel and TableLayoutPanel classes, extend the Panel class by adding specific child control positioning logic. Use either of these controls to implement a very specific set of child control layout scenarios. In simple scenarios, as shown in Figure 8, the result of using either control may not be uniquely distinguishable from the other.

The FlowLayoutPanel class, mentioned in the Whidbey documentation as the FlowPanel class, is used as a container control when the child controls added are dynamically repositioned to flow in a particular direction. The FlowLayoutPanel automatically positions all child controls in the direction indicated by the value of the FlowDirection property. You can leave the WrapContents property set to the default value of True to force the controls to stay within the boundaries of the SplitContainer class by starting a new row or column, depending on the value of the FlowDirection property. In Figure 9, a FlowLayoutPanel control with a FlowDirection value of Horizontal moves the controls when one of the child controls is increased in size. The TableLayoutPanel class, mentioned in the Whidbey documentation as the GridPanel class, implements different positioning logic than the FlowLayoutPanel class. The FlowDirection and WrapContents property of the FlowLayoutPanel are replaced with integer-based Columns and Rows properties. The TableLayoutPanel class implicitly positions child controls in a table format, which, assuming default values of 0 for both Columns and Rows, mimics a FlowLayoutPanel instance with FlowDirection set to Horizontal and WrapContents set to True.

Figure 9. The TableLayoutPanel Class: This class maintains a structured approach to repositioning child controls and the FlowLayoutPanel class offers a more lenient set of positioning rules.
You set either Columns or Rows to a non-zero positive value to limit the cells in either dimension of the table. Increasing the size of a child control shifts the cell size in the table containing the child control to accommodate the larger child control, as shown in Figure 9. This pushes other child controls away from the growing control.


An exception is raised if you set values for Columns and Rows that combine to produce too few cells in the table to hold all the child controls. The TableLayoutPanel class provides ColumnStyles and RowStyles properties. Use these collection-based properties to modify sizing properties at the individual row and column level.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date