DDDFF
DDDFF
the Choose Toolbox Items dialog (Fig. 15.52). If it’s not already checked, check
this item. Click OK to add the item to the Toolbox. This control can now be add-
ed to the Form as if it were any other control.
15.15 Wrap-Up
Many of today’s commercial apps provide GUIs that are easy to use and manipulate. Because
of this demand for user-friendly GUIs, the ability to design sophisticated GUIs is an essential
programming skill. Visual Studio’s IDE makes GUI development quick and easy. In
Chapters 14 and 15, we presented basic Windows Forms GUI development techniques. In
Chapter 15, we demonstrated how to create menus, which provide users easy access to an
app’s functionality. You learned the DateTimePicker and MonthCalendar controls, which
allow users to input date and time values. We demonstrated LinkLabels, which are used to
link the user to an app or a web page. You used several controls that provide lists of data to
the user—ListBoxes, CheckedListBoxes and ListViews. We used the ComboBox control to
create drop-down lists, and the TreeView control to display data in hierarchical form. We
then introduced complex GUIs that use tabbed windows and multiple document interfaces.
The chapter concluded with demonstrations of visual inheritance and creating custom con-
trols. In Chapter 16, we introduce string and character processing.
Summary
Section 15.2 Menus
• Menus provide groups of related commands for Windows Forms apps.
• An expanded menu lists menu items and submenus.
• A menu that contains a menu item is called that menu item’s parent menu. A menu item that
contains a submenu is considered to be the parent of that submenu.
Summary 631
• The simplest way to create a custom control is to derive a class from an existing control, such as
a Label. This is useful if you want to add functionality to an existing control, rather than replac-
ing it with one that provides the desired functionality.
• To create a new control composed of existing controls, use class UserControl.
• Controls added to a custom control are called constituent controls.
• A programmer can create a brand-new control by inheriting from class Control. This class does
not define any specific behavior; that task is left to you.
• Timers are non-visual components that generate Tick events at a set interval. This interval is set
by the Timer’s Interval property, which defines the number of milliseconds (thousandths of a
second) between events. Timers are disabled by default.
Terminology
access shortcut CheckedListBox class
Activation property of class ListView child node
ActiveMdiChild property of class Form child window
AddDays method of struct DateTime Clear method of class Graphics
AddYears method of struct DateTime Click event of class ToolStripMenuItem
Application class ClipRectangle property of class
cascaded window PaintEventArgs
CheckBoxes property of class ListView ComboBox class
Checked property of class ToolStripMenuItem ComboBoxStyle enumeration
634 Chapter 15 Graphical User Interfaces with Windows Forms: Part 2
Self-Review Exercises
15.1 State whether each of the following is true or false. If false, explain why.
a) Menus provide groups of related classes.
b) Menu items can display ComboBoxes, checkmarks and access shortcuts.
c) The ListBox control allows only single selection (like a RadioButton).
d) A ComboBox control typically has a drop-down list.
e) Deleting a parent node in a TreeView control deletes its child nodes.
f) The user can select only one item in a ListView control.
g) A TabPage can act as a container for RadioButtons.
h) An MDI child window can have MDI children.
i) MDI child windows can be moved outside the boundaries of their parent window.
j) There are two basic ways to create a customized control.
15.2 Fill in the blanks in each of the following statements:
a) Method of class Process can open files and web pages, similar to the Run...
command in Windows.
b) If more elements appear in a ComboBox than can fit, a(n) appears.
c) The top-level node in a TreeView is the node.
d) A(n) and a(n) can display icons contained in an ImageList control.
e) The property allows a menu to display a list of active child windows.
f) Class allows you to combine several controls into a single,custom control.
g) The saves space by layering TabPages on top of each other.
h) The window layout option makes all MDI windows the same size and layers
them so every title bar is visible (if possible).
i) are typically used to display hyperlinks to other resources, files or web pages.
Exercises
15.3 (Using ComboBoxes) Write an app that displays the names of 15 states in a ComboBox. When
an item is selected from the ComboBox, remove it.
15.4 (Using ComboBoxes and ListBoxes) 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