Wrap-Up

Answers to Self Review Exercises

14.1

a) False. Menus provide groups of related commands. b) True. c) False. Both controls can have single or multiple selection. d) True. e) True. f) False. The user can select one or more items. g) True. h) False. Only an MDI parent window can have MDI children. An MDI parent window cannot be an MDI child. i) False. MDI child windows cannot be moved outside their parent window. j) False. There are three ways: 1) Derive from an existing control, 2) use a UserControl or 3) derive from Control and create a control from scratch.

14.2

a) Start. b) scrollbar. c) root. d) ListView, treeView. e) MdiList. f) UserControl. g) TabControl. h) Cascade. i) LinkLabels.

Exercises

14.3

Write a program that displays the names of 15 states in a ComboBox. When an item is selected from the ComboBox, remove it.

 
14.4

Modify your solution to the previous exercise to add a ListBox. When the user selects an item from the ComboBox, remove the item from the ComboBox and add it to the ListBox. Your program should check to ensure that the ComboBox contains at least one item. If it does not, print a message, using a message box, then terminate program execution when the user dismisses the message box.

14.5

Write a program that allows the user to enter strings in a TextBox. Each string input is added to a ListBox. As each string is added to the ListBox, ensure that the strings are in sorted order. [Note: Use property Sorted.]

14.6

Create a file browser (similar to Windows Explorer) based on the programs in Fig. 14.14, Fig. 14.28 and Fig. 14.31. The file browser should have a treeView, which allows the user to browse directories. There should also be a ListView, which displays the contents (all subdirectories and files) of the directory being browsed. Double clicking a file in the ListView should open it, and double clicking a directory in either the ListView or the TReeView should browse it. If a file or directory cannot be accessed because of its permission settings, notify the user.

14.7

Create an MDI text editor. Each child window should contain a multiline RichTextBox. The MDI parent should have a Format menu, with submenus to control the size, font and color of the text in the active child window. Each submenu should have at least three options. In addition, the parent should have a File menu, with menu items New (create a new child), Close (close the active child) and Exit (exit the application). The parent should have a Window menu to display a list of the open child windows and their layout options.

14.8

Create a UserControl called LoginPasswordUserControl. The LoginPasswordUserControl contains a Label (loginLabel) that displays string "Login:", a TextBox (loginTextBox) where the user inputs a login name, a Label (passwordLabel) that displays the string "Password:" and finally, a TextBox (passwordTextBox) where a user inputs a password (do not forget to set property PasswordChar to "*" in the TextBox's Properties window). LoginPasswordUserControl must provide Public read-only properties Login and Password that allow an application to retrieve the user input from loginTextBox and passwordTextBox. The UserControl must be exported to an application that displays the values input by the user in LoginPasswordUserControl.

14.9

A restaurant wants an application that calculates a table's bill. The application should display all the menu items from Fig. 14.53 in four ComboBoxes. Each ComboBox should contain a category of food offered by the restaurant (Beverage, Appetizer, Main Course and Dessert). The user can choose from one of these ComboBoxes to add an item to a table's bill. As each item is selected in the ComboBoxes, add the price of that item to the bill. The user can click the Clear Button to restore the Subtotal:, Tax: and Total: fields to $0.00.

Figure 14.53. Food items and prices.

Name

Category

Price

Soda

Beverage

$1.95

Tea

Beverage

$1.50

Coffee

Beverage

$1.25

Mineral Water

Beverage

$2.95

Juice

Beverage

$2.50

Milk

Beverage

$1.50

Buffalo Wings

Appetizer

$5.95

Buffalo Fingers

Appetizer

$6.95

Potato Skins

Appetizer

$8.95

Nachos

Appetizer

$8.95

Mushroom Caps

Appetizer

$10.95

Shrimp Cocktail

Appetizer

$12.95

Chips and Salsa

Appetizer

$6.95

Seafood Alfredo

Main Course

$15.95

Chicken Alfredo

Main Course

$13.95

Chicken Picatta

Main Course

$13.95

Turkey Club

Main Course

$11.95

Lobster Pie

Main Course

$19.95

Prime Rib

Main Course

$20.95

Shrimp Scampi

Main Course

$18.95

Turkey Dinner

Main Course

$13.95

Stuffed Chicken

Main Course

$14.95

Apple Pie

Dessert

$5.95

Sundae

Dessert

$3.95

Carrot Cake

Dessert

$5.95

Mud Pie

Dessert

$4.95

Apple Crisp

Dessert

$5.95

 
14.10

Create an application that contains three TabPages. On the first TabPage, place a CheckedListBox with six items. On the second TabPage, place six TextBoxes. On the last TabPage, place six LinkLabels. The user's selections on the first TabPage should specify which of the six LinkLabels will be displayed. To hide or display a LinkLabel's value, use its Visible property. Use the second TabPage to modify the Web page that is opened by the LinkLabels. [Note: To change the LinkLabels' Visible properties, you will need to change the currently displayed TabPage to the last one. To do this, use the TabPage's SelectedTab property.]

14.11

Create an MDI application with child windows that each have a Panel for drawing. Add menus to the MDI application that allow the user to modify the size and color of the paint brush. When running this application, be aware that if one of the windows overlaps another, the Panel will be cleared.

Multithreading

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