Exercises

  1. 2.3 Fill in the blanks in each of the following statements:

    1. When an ellipsis button is clicked, a(n)                  is displayed.

    2. Using                  help immediately displays a relevant help article.

    3. GUI is an acronym for                 .

    4. The                  property specifies which image a PictureBox displays.

    5. The                  menu contains commands for arranging and displaying windows.

  2. 2.4 State whether each of the following is true or false. If false, explain why.

    1. You can add a control to a Form by double clicking its control icon in the Toolbox.

    2. The Form, Label and PictureBox have identical properties.

    3. If your machine is connected to the Internet, you can browse websites from the Visual Studio IDE.

    4. Visual C# app developers usually create complex apps without writing any code.

    5. Sizing handles are visible during execution.

  3. 2.5 Some features that appear throughout Visual Studio perform similar actions in different contexts. Explain and give examples of how the ellipsis buttons, down-arrow buttons and tool tips act in this manner. Why do you think the Visual Studio IDE was designed this way?

  4. 2.6 Briefly describe each of the following terms:

    1. toolbar

    2. menu bar

    3. Toolbox

    4. control

    5. Form

    6. solution

Note Regarding Exercises 2.7–2.11

In the following exercises, you’re asked to create GUIs using controls that we have not yet discussed in this book. These exercises give you practice with visual app development only—the apps do not perform any actions. You place controls from the Toolbox on a Form to familiarize yourself with what each control looks like. If you follow the step-by-step instructions, you should be able to recreate the sample GUIs we show.

  1. 2.7 (Notepad GUI) Create the GUI for the notepad as shown in Fig. 2.36.

    1. Manipulating the Form’s properties. Change the Text property of the Form to My Note-pad. Change the Font property to 9pt Segoe UI—the recommended font for Windows apps.

    2. Adding a MenuStrip control to the Form. Add a MenuStrip to the Form. After inserting the MenuStrip, add items by clicking the Type Here section, typing a menu name (for example, File, Edit, View and About) and then pressing Enter.

      Fig. 2.36 Notepad GUI.

    3. Adding a RichTextBox to the Form. Drag this control onto the Form. Use the sizing handles to resize and position the RichTextBox as shown in Fig. 2.36. Change the Text property to Enter text here.

  2. 2.8 (Calendar and Appointments GUI) Create the GUI for the calendar as shown in Fig. 2.37.

    Fig. 2.37 Calendar and appointments GUI.

    1. Manipulating the Form’s properties. Change the Text property of the Form to My Scheduler. Change the Font property to 9pt Segoe UI. Set the Form’s Size property to 275, 400.

    2. Adding Labels to the Form. Add two Labels to the Form. Both should be of equal size (231, 23; remember to set the AutoSize property to False) and should be centered in the Form horizontally, as shown. Set the Label’s Text properties to match Fig. 2.37. Use 12-point font size. Also, set the BackColor property to Yellow.

    3. 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.

    4. 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.

  3. 2.9 (Calculator GUI) Create the GUI for the calculator as shown in Fig. 2.38.

    Fig. 2.38 Calculator GUI.

    1. Manipulating the Form’s properties. Change the Text property of the Form to Calculator. Change the Font property to 9pt Segoe UI. Change the Size property of the Form to 258, 210.

    2. Adding a TextBox to the Form. Set the TextBox’s Text property in the Properties window to 0. Stretch the TextBox and position it as shown in Fig. 2.38. Set the TextAlign property to Right—this right aligns text displayed in the TextBox.

    3. Adding the first Panel to the Form. Panel controls are used to group other controls. Add a Panel to the Form. Change the Panel’s BorderStyle property to Fixed3D to make the inside of the Panel appear recessed. Change the Size property to 90, 120. This Panel will contain the calculator’s numeric keys.

    4. Adding the second Panel to the Form. Change the Panel’s BorderStyle property to Fixed3D. Change the Size property to 62, 120. This Panel will contain the calculator’s operator keys.

    5. Adding the third (and last) Panel to the Form. Change the Panel’s BorderStyle property to Fixed3D. Change the Size property to 54, 62. This Panel contains the calculator’s C (clear) and C/A (clear all) keys.

    6. 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. Each Button labeled 0–9, *, /, -, = and . should have a size of 23, 23. The 00 Button has size 52, 23. The OFF Button has size 54, 23. The + Button is sized 23, 81. The C (clear) and C/A (clear all) Buttons are sized 44, 23.

  4. 2.10 (Alarm Clock GUI) Create the GUI for the alarm clock as shown in Fig. 2.39.

    Fig. 2.39 Alarm clock GUI.

    1. Manipulating the Form’s properties. Change the Text property of the Form to Alarm Clock. Change the Font property to 9pt Segoe UI. Change the Size property of the Form to 438, 170.

    2. Adding Buttons to the Form. Add seven Buttons to the Form. Change the Text property of each Button to the appropriate text. Align the Buttons as shown.

    3. Adding a GroupBox to the Form. GroupBoxes are like Panels, except that GroupBoxes display a title. Change the Text property to AM/PM, and set the Size property to 100, 50. Center the GroupBox horizontally on the Form.

    4. Adding AM/PM RadioButtons to the GroupBox. Place two RadioButtons in the GroupBox. Change the Text property of one RadioButton to AM and the other to PM. Align the RadioButtons as shown.

    5. 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. Use the Font property to make the time bold and 12pt. Change the ForeColor to Silver (located in the Web tab) to make the time stand out against the black background. Position the Label as shown.

  5. 2.11 (Radio GUI) Create the GUI for the radio as shown in Fig. 2.40. [Note: The image used in this exercise is located in this chapter’s examples folder.]

    Fig. 2.40 Radio GUI.

    1. Manipulating the Form’s properties. Change the Font property to 9pt Segoe UI. Change the Form’s Text property to Radio and the Size to 427, 194.

    2. Adding the Pre-set Stations GroupBox and Buttons. Set the GroupBox’s Size to 180, 55 and its Text to Pre-set Stations. Add six Buttons to the GroupBox. Set each one’s Size to 23, 23. Change the Buttons’ Text properties to 1, 2, 3, 4, 5, 6, respectively.

    3. Adding the Speakers GroupBox and CheckBoxes. Set the GroupBox’s Size to 120, 55 and its Text to Speakers. Add two CheckBoxes to the GroupBox. Set the Text properties for the CheckBoxes to Rear and Front.

    4. Adding the Power On/Off Button. Add a Button to the Form. Set its Text to Power On/ Off and its Size to 75, 55.

    5. Adding the Volume Control GroupBox, the Mute CheckBox and the Volume TrackBar. Add a GroupBox to the Form. Set its Text to Volume Control and its Size to 180, 70. Add a CheckBox to the GroupBox. Set its Text to Mute. Add a TrackBar to the GroupBox.

    6. Adding the Tuning GroupBox, the radio station Label and the AM/FM RadioButtons. Add a GroupBox to the Form. Set its Text to Tuning and its Size to 120, 70. Add a Label to the GroupBox. Set its AutoSize to False, its Size to 50, 44, its BackColor to Black, its ForeColor to Silver, its font to 12pt bold and its TextAlign to MiddleCenter. Set its Text to 92.9. Place the Label as shown in the figure. Add two RadioButtons to the GroupBox. Set the Text of one to AM and of the other to FM.

    7. Adding the image. Add a PictureBox to the Form. Set its SizeMode to StretchImage and its Size to 55, 70. Set the Image property to MusicNote.gif (located in this chapter’s examples folder).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset