44
LESSON 3 Making Controls arrange theMselves
Use the
Anchor property to make the ListBox stretch vertically when the form resizes.
1. Set the ListBox’s Anchor property to Top, Bottom, Left.
Use
Anchor properties to make the TextBoxes and LinkLabel stretch horizontally when the
form resizes.
1. Set the GroupBox’s Anchor property to Top, Bottom, Left, Right.
2. Set the TextBoxes’ and the LinkLabel’s Anchor property to Top, Left, Right.
Use
Anchor properties to make the PictureBox resize vertically when the form resizes.
1. Set the PictureBox’s Anchor property to Top, Bottom, Left.
Run the program and see what happens when you resize the form.
Please select Lesson 3 on the DVD to view the video that accompanies this lesson.
EXERCISES
1. (SimpleEdit) Create a new project named SimpleEdit, putting it somewhere you can easily
find so you can add enhancements in later lessons. Give it a
MenuStrip and StatusStrip
with appropriate (default)
Dock values. Add a RichTextBox control and set its Dock property
to
Fill. (That’s all for now. In later lessons you add features to this program.)
2. Make a New Customer dialog box similar to the one shown
in Figure 3-9. Make the First Name, Last Name, Street, City,
and Email
TextBoxes resize horizontally when the form
resizes. Use the OK and Cancel buttons as the form’s accept
and cancel buttons, and attach them to the form’s lower-
right corner.
3. The SplitContainer control displays two areas sepa-
rated by a splitter. The user can drag the splitter to
divide the available space between the two areas. Make
a program similar to the one shown in Figure 3-10. Feel
free to use a different picture and information. Make
the
PictureBox display its image as large as possible
without distortion. Set the bottom
TextBox’s MultiLine
property to
True and make it stretch vertically and horizontally as the form resizes. Make
the other
TextBoxes stretch horizontally. Set the SplitContainer’s Panel1MinSize and
Panel2MinSize properties to 100.
FIGURE 39
596906c03.indd 44 4/7/10 12:31:42 PM