property of the big label appropriately. Don’t worry about the rules such as not allowing some-
one to claim a square that is already claimed.)
3. Modify the tic-tac-toe program from Exercise 2 so instead of
displaying X or O in each square, it displays a picture. Use
your favorite football team logos, a cat and a dog, your pic-
ture and your boss’s, or whatever. (Hints: Use
PictureBoxes
instead of the large
Labels. Add two hidden PictureBoxes
to the form. To set their
Image properties, click the ellipsis
next to the
Image property in the Properties window, click the
Import button, and browse for the image files. Finally, instead
of setting a
Label’s Text property, the Click event handlers
should set the appropriate
PictureBox’s Image property
equal to one of the hidden
PictureBox’s Image properties.
Set all
PictureBoxes’ SizeMode properties to Zoom.)
4. Make a program with a Label that says “Move Me” and four Buttons with text (0, 0),
(200, 200), (200, 0), and (0, 200). Make each
Button move the Label to the corresponding
position by setting its
Left and Top properties.
5. The solution to Exercise 4 moves its Label in two steps by setting its Left and Top properties.
Modify the program so it sets the
Label’s Location property in a single step using code similar
to this:
moveMeLabel.Location = new Point(0, 0);
6. Build a menu selection form similar to the one
shown in Figure 2-12. (Hints: Copy and paste
the
Labels and TextBoxes from the Try It pro-
gram. To set the
PictureBox’s image, look in the
Properties window and click the ellipsis next to
the
Image property. In the Select Resource dialog
box, click Import and browse to select a picture.
Finally, set the
PictureBox’s SizeMode property
to
AutoSize.)
You can download the solutions to these exercises from the book’s web page at
www.wrox.com or www.CSharpHelper.com/24hour.html. You can find them in
the Lesson02 folder.
FIGURE 211
FIGURE 212
596906c02.indd 35 4/7/10 12:31:36 PM
Click here to Play