Exercises
2.3 |
Fill in the blanks in each of the following statements:
- When an ellipsis button is clicked, a(n) __________ is displayed.
- To save every file in a solution, select __________.
- Using __________ help immediately displays a relevant help article. It can be accessed using the __________ key.
- GUI is an acronym for __________.
|
2.4 |
State whether each of the following is true or false. If false, explain why.
- A control can be added to a form by double clicking its control icon in the Toolbox.
- The form, Label and PictureBox have identical properties.
- If your machine is connected to the Internet, you can browse the Internet from the Visual Studio 2005 IDE.
- Visual C# programmers usually create complex programs without writing any code.
- Sizing handles are visible during execution.
|
2.5 |
Some features that appear throughout Visual Studio perform similar actions in different contexts. Explain and give examples of how the plus and minus boxes, ellipsis buttons, down-arrow buttons and tool tips act in this manner. Why do you think the Visual Studio 2005 IDE was designed this way?
|
2.6 |
Fill in the blanks in each of the following statements:
- The __________ property specifies which image a PictureBox displays.
- The __________ menu contains commands for arranging and displaying windows.
- The __________ property determines a form's or control's background color.
|
2.7 |
Briefly describe each of the following terms:
- toolbar
- menu bar
- Toolbox
- control
- form
- solution
[Note: In the following exercises, you are asked to create GUIs using controls that we have not yet discussed in this book. The exercises will give you practice with visual programming onlythe programs will not perform any actions. You will be placing controls from the Toolbox on a form to familiarize yourself with what each control looks like. We have provided step-by-step instructions for you. If you follow these, you should be able to replicate the screen images we provide.]
|
|
|
2.8 |
(Notepad GUI) Create the GUI for the notepad as shown in Fig. 2.50.
- Manipulating the Form's properties. Change the Text property of the Form to My Notepad.
- Adding a MenuStrip to the Form. After inserting the MenuStrip, add items by clicking the Type Here section, typing a menu name (e.g., File, Edit, View and About), then pressing Enter.
- Adding a RichTextBox to the Form. Change the Size property to 267, 220 or use the sizing handles to resize the RichTextBox to the correct size. Change the Text property to Enter Text Here. Finally, set the Location property to 13, 34.
Figure 2.50. Notepad GUI.
|
2.9 |
(Calendar and Appointments GUI) Create the GUI for the calendar and appointments as shown in Fig. 2.51.
- Manipulating the Form's properties. Change the Text property of the Form to My Scheduler. Set the Form's Size property to 332, 470.
- Adding Labels to the Form. Add two Labels to the Form. Set the Labels' AutoSize properties to False. Both should be of equal size (178, 21) and should be centered in the Form horizontally, as shown. Set the Label's Text properties to match the figure as shown, using 12-point font size. Also set the BackColor property to Yellow.
- Adding a MonthCalendar control to the Form. Add this control to the Form and center it horizontally in the appropriate place between the two Labels.
- Adding a RichTextBox control to the Form. Add a RichTextBox control to the Form and center it below the second Label. Resize the RichTextBox accordingly.
Figure 2.51. Calendar and Appointments GUI.
(This item is displayed on page 72 in the print version)
|
2.10 |
(Calculator GUI) Create the GUI for the calculator as shown in Fig. 2.52.
- Manipulating the Form's properties. Change the Size property of the Form to 272, 192. Change the Text property of the Form to Calculator.
- Adding a TextBox to the Form. Set the TextBox's Text property in the Properties window to 0. Change the Size property to 240, 20. Set the TextAlign property to Right; this right aligns text displayed in the TextBox. Finally, set the TextBox's Location property to 8, 16.
- Adding the first Panel to the Form. Panel controls are used to group other controls. Change the Panel's BorderStyle property to Fixed3D to make the inside of the Panel appear recessed. Change the Size property to 88, 108. Finally, set the Location property to 8, 48. This Panel contains the calculator's numeric keys.
- Adding the second Panel to the Form. Change the Panel's BorderStyle property to Fixed3D. Change the Size property to 72, 108. Finally, set the Location property to 112, 48. This Panel contains the calculator's operator keys.
- Adding the third (and last) Panel to the Form. Change the Panel's BorderStyle property to Fixed3D. Change the Size property to 48, 72. Finally, set the Location property to 200, 48. This Panel contains the calculator's C (clear) and C/A (clear all) keys.
- Adding Buttons to the Form. There are 20 Buttons on the calculator. Add a Button to the Panel by dragging and dropping it on the Panel. Change the Text property of each Button to the calculator key it represents. The value you enter in the Text property will appear on the face of the Button. Finally, resize the Buttons, using their Size properties. The Buttons labeled 09, x, /, -, = and . should have a size of 24, 24. The 00 and OFF Buttons are sized 48, 24. The + Button is sized 24, 64. The C (clear) and C/A (clear all) Buttons are sized 32, 24.
Figure 2.52. Calculator GUI.
|
2.11 |
(Alarm Clock GUI) Create the GUI for the alarm clock as shown in Fig. 2.53.
- Manipulating the Form's properties. Change the Size property of the Form to 256, 176. Change the Form's Text property to Alarm Clock.
- Adding Buttons to the Form. Add six Buttons to the Form. Change the Text property of each Button to the appropriate text. Change the Size properties of the Hour, Minute and Second Buttons to 56, 23. The ON and OFF Buttons are sized 40, 23. The Timer Button is sized 48, 32. Align the Buttons as shown.
- Adding a Label to the Form. Add a Label to the Form. Change the Text property to Snooze and set the AutoSize property to False. Set its Size to 248, 23. Set the Label's TextAlign property to MiddleCenter. Finally, to draw a border around the edge of the Snooze Label, change the BorderStyle property of the Snooze Label to FixedSingle.
- Adding a GroupBox to the Form. GroupBoxes are like Panels, except that GroupBoxes can display a title. Change the Text property to AM/PM, and set the Size property to 72, 72. To place the GroupBox in the correct location on the Form, set the Location property to 104, 38.
- Adding AM/PM RadioButtons to the GroupBox. Change the Text property of one RadioButton to AM and the other to PM, then set the AutoSize property of each RadioButton to False. Then place the RadioButtons as shown by setting the Location of the AM RadioButton to 16, 16 and that of the PM RadioButton to 16, 40. Set their Size properties to 48, 24.
- Adding the time Label to the Form. Add a Label to the Form and change its Text property to 00:00:00. Change the BorderStyle property to Fixed3D and the BackColor to Black. Set the AutoSize property to False, then set the Size property to 64, 23. Use the Font property to make the time bold. Change the ForeColor to Silver (located in the Web tab) to make the time stand out against the black background. Set TextAlign to MiddleCenter to center the text in the Label. Position the Label as shown.
Figure 2.53. Alarm clock GUI.
|
2.12 |
(Radio GUI) Create the GUI for the radio as shown in Fig. 2.54. [Note: All colors used in this exercise are from the Web palette, and the image can be found in the examples folder for Chapter 2.]
- Manipulating the Form's properties. Change the Form's Text property to Radio and the Size to 576, 240. Set BackColor to PeachPuff.
- Adding the Pre-set Stations GroupBox and Buttons. Set the GroupBox's Size to 232, 64, its Text to Pre-set Stations, its ForeColor to Black and its BackColor to RosyBrown. Change its Font to bold. Finally, set its Location to 24, 16. Add six Buttons to the GroupBox. Set each BackColor to PeachPuff and each Size to 24, 23. Change the Buttons' Text properties to 1, 2, 3, 4, 5 and 6, respectively.
- Adding the Speakers GroupBox and CheckBoxes. Set the GroupBox's AutoSize property to False, then set its Size to 160, 72, its Text to Speakers and its ForeColor to Black. Set its Location to 280, 16. Add two CheckBoxes to the GroupBox. Set each CheckBox's Size to 56, 24. Set the Text properties for the CheckBoxes to Rear and Front.
- Adding the Power On/Off Button. Add a Button to the Form. Set its Text to Power On/Off, its BackColor to RosyBrown, its ForeColor to Black and its Size to 72, 64. Change its Font style to Bold.
- Adding the Volume Control GroupBox, the Mute CheckBox and the Volume trackBar. Add a GroupBox to the Form. Set its Text to Volume Control, its BackColor to RosyBrown, its ForeColor to Black and its Size to 200, 80. Set its Font style to Bold. Add a CheckBox to the GroupBox. Set its Text to Mute, its AutoSize property to False and its Size to 56, 24. Add a TRackBar to the GroupBox.
- Adding the Tuning GroupBox, the radio station Label and the AM/FM RadioButtons. Add a GroupBox to the Form. Set its Text to Tuning, its ForeColor to Black and its BackColor to RosyBrown. Set its Font style to Bold and its Size to 216, 80. Add a Label to the GroupBox. Set its BackColor to PeachPuff, its ForeColor to Black, its BorderStyle to FixedSingle, its Font style to Bold, its TextAlign to MiddleCenter, its AutoSize to False and its Size to 56, 23. Set its Text to 92.9. Place the Label as shown in the figure. Add two RadioButtons to the GroupBox. Change the BackColor to PeachPuff, set the AutoSize to False and change the Size to 40,24. Set the Text of one to AM and the other's to FM.
- Adding the image. Add a PictureBox to the Form. Set its BackColor to TRansparent, its SizeMode to StretchImage and its Size to 66, 85. Set the Image property to MusicNote.gif (located in the examples folder for Chapter 2).
Figure 2.54. Radio GUI.
|
|