Web Resources

Answers to Self Review Exercises

2.1

a) visual programming. b) solution. c) auto-hide. d) tool tip. e) Solution Explorer. f) expand. g) alphabetically, categorically. h) Text. i) Toolbox. j) Dynamic Help. k) TextAlign.

2.2

a) True. b) False. The pin icon toggles auto-hide. The X box closes a window. c) True. d) False. The Toolbox contains icons that represent controls. e) False. Forms have a title bar but Labels do not (although they do have Label text). f) False. Control properties can be modified using the Properties window. g) True. h) False. Visual C# files use the filename extension .cs. i) True.

Exercises

2.3

Fill in the blanks in each of the following statements:

  1. When an ellipsis button is clicked, a(n) __________ is displayed.
  2. To save every file in a solution, select __________.
  3. Using __________ help immediately displays a relevant help article. It can be accessed using the __________ key.
  4. GUI is an acronym for __________.
2.4

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

  1. A control can be added 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 the Internet from the Visual Studio 2005 IDE.
  4. Visual C# programmers usually create complex programs without writing any code.
  5. 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:

  1. The __________ property specifies which image a PictureBox displays.
  2. The __________ menu contains commands for arranging and displaying windows.
  3. The __________ property determines a form's or control's background color.
2.7

Briefly describe each of the following terms:

  1. toolbar
  2. menu bar
  3. Toolbox
  4. control
  5. form
  6. 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.

  1. Manipulating the Form's properties. Change the Text property of the Form to My Notepad.
  2. 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.
  3. 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.

  1. Manipulating the Form's properties. Change the Text property of the Form to My Scheduler. Set the Form's Size property to 332, 470.
  2. 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.
  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.

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.

  1. Manipulating the Form's properties. Change the Size property of the Form to 272, 192. Change the Text property of the Form to Calculator.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  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. 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.

  1. Manipulating the Form's properties. Change the Size property of the Form to 256, 176. Change the Form's Text property to Alarm Clock.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.]

  1. Manipulating the Form's properties. Change the Form's Text property to Radio and the Size to 576, 240. Set BackColor to PeachPuff.
  2. 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.
  3. 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.
  4. 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.
  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, 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.
  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, 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.
  7. 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.


Preface

Index

    Introduction to Computers, the Internet and Visual C#

    Introduction to the Visual C# 2005 Express Edition IDE

    Introduction to C# Applications

    Introduction to Classes and Objects

    Control Statements: Part 1

    Control Statements: Part 2

    Methods: A Deeper Look

    Arrays

    Classes and Objects: A Deeper Look

    Object-Oriented Programming: Inheritance

    Polymorphism, Interfaces & Operator Overloading

    Exception Handling

    Graphical User Interface Concepts: Part 1

    Graphical User Interface Concepts: Part 2

    Multithreading

    Strings, Characters and Regular Expressions

    Graphics and Multimedia

    Files and Streams

    Extensible Markup Language (XML)

    Database, SQL and ADO.NET

    ASP.NET 2.0, Web Forms and Web Controls

    Web Services

    Networking: Streams-Based Sockets and Datagrams

    Searching and Sorting

    Data Structures

    Generics

    Collections

    Appendix A. Operator Precedence Chart

    Appendix B. Number Systems

    Appendix C. Using the Visual Studio 2005 Debugger

    Appendix D. ASCII Character Set

    Appendix E. Unicode®

    Appendix F. Introduction to XHTML: Part 1

    Appendix G. Introduction to XHTML: Part 2

    Appendix H. HTML/XHTML Special Characters

    Appendix I. HTML/XHTML Colors

    Appendix J. ATM Case Study Code

    Appendix K. UML 2: Additional Diagram Types

    Appendix L. Simple Types

    Index



    Visual C# How to Program
    Visual C# 2005 How to Program (2nd Edition)
    ISBN: 0131525239
    EAN: 2147483647
    Year: 2004
    Pages: 600

    Flylib.com © 2008-2020.
    If you may any questions please contact us: flylib@qtcs.net