Answers to Self Review Exercises


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.


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



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


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.


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


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.


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.


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.


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.













Mineral Water









Buffalo Wings



Buffalo Fingers



Potato Skins






Mushroom Caps



Shrimp Cocktail



Chips and Salsa



Seafood Alfredo

Main Course


Chicken Alfredo

Main Course


Chicken Picatta

Main Course


Turkey Club

Main Course


Lobster Pie

Main Course


Prime Rib

Main Course


Shrimp Scampi

Main Course


Turkey Dinner

Main Course


Stuffed Chicken

Main Course


Apple Pie






Carrot Cake



Mud Pie



Apple Crisp




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


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.




    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


    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


    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



    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


    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