
42
LESSON 3 Making Controls arrange theMselves
TRY IT
In this Try It, you have a chance to practice using the Anchor and Dock properties. You build the
application shown in Figure 3-8.
FIGURE 38
When the form resizes, the TextBoxes and LinkLabel stretch horizontally.
When the form resizes, the
PictureBox also stretches vertically. Notice in Figure 3-8 that the cover
image is rather tall and thin. When the
PictureBox grows taller, it can display a larger version of
the cover image. The control displays the image as large as possible without distorting it.
Note that the program you build won’t actually do anything except sit there looking pretty and
resizing controls when the form resizes. The techniques you need to make it respond to list selections
are covered in later lessons.
You can download the code and resources for this Try It from the book’s web
page at
www.wrox.com or www.CSharpHelper.com/24hour.html. You can find
them in the Lesson03 folder in the download.
Lesson Requirements
In this lesson, you:
Create the program’s three main controls: a
MenuStrip, a Panel, and a StatusStrip. Use
Dock properties to make these three controls stay in their proper positions.
Add controls to the
Panel.
Use the
Anchor property to make the ListBox stretch vertically when the form resizes.
Use
Anchor properties to make the TextBoxes and LinkLabel stretch horizontally when the
form resizes. ...