Panel


The Panel control is a container of other controls. By setting the Anchor and Dock properties of the contained controls, you can make those controls arrange themselves when the Panel is resized.

You can use a Panel to make it easy to manipulate the controls it contains as a group. If you move the Panel, then the controls it contains move also. If you set the Panel control’s Visible property to False, then the controls it contains are hidden. If you set the Panel control’s Enabled property to False, then the controls it contains are also disabled.

Similarly, you can set the Panel control’s other style properties such as BackColor, ForeColor, and Font and any controls contained in the Panel inherit these values (although a few controls insist on keeping their own values for some properties, such as the TextBox control’s ForeColor and Back?Color properties).

A Panel also defines a separate group for radio buttons. If you have two Panel controls, each containing several radio buttons, then the two groups of buttons work independently, so clicking a button in one Panel doesn’t deselect the buttons in the other Panel.

The most advanced feature of the Panel control is its auto-scroll capability. If you set the AutoScroll property to True, then the control automatically provides working scroll bars if the controls that it contains won’t fit. The AutoScrollMargin property lets you define extra space that the control should add around its contents when it is auto-scrolling.

Use the AutoScrollMinSize property to ensure that the control’s scrolling area is at least a certain minimum size. For example, suppose that the Panel contains controls with coordinates between 0 and 100 in both the X and Y directions. Normally, the control would let you scroll over the area 0 <= X <= 100, 0 <= Y <= 100 so that you can see all of the controls. If you set AutoScrollMinSize to 200, 50, then the control would let you scroll over the area 0 <= X <= 200, 0 <= Y <= 100 so that you can see the controls plus the area defined by AutoScrollMinSize.

The AutoScrollPosition property lets your program get or set the scroll bars’ position at runtime. For example, the following code makes the panMap control scroll to make the upper-left corner of its contents visible:

  panMap.AutoScrollPosition = New Point(0, 0) 

If you set AutoScrollPosition to a point that is outside of the Panel’s display area, the control adjusts the point so that it lies within the area.

Although a program often uses a Panel control as an invisible container for other controls, you can use its BackColor and BorderStyle properties to make it visible if you like.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net