understand how to create new controls and extend existing controls 98-362 windows development...
DESCRIPTION
Windows Development Fundamentals LESSON 2.3A Anticipatory Set With a partner, create a list of controls that are often used together in a Windows Form, or sets of controls that are commonly used on multiple forms.TRANSCRIPT
Understand How to Create New Controls and Extend Existing Controls
98-362 Windows Development Fundamentals
LESSON 2.3A
98-362 Windows Development Fundamentals
LESSON 2.3A
Lesson Overview
How can a developer design and implement custom GUI controls?
In this lesson, you will learn about: Different types of custom controls Determining which type of custom control to use to fit a situation Creating user controls
98-362 Windows Development Fundamentals
LESSON 2.3A
Anticipatory Set
With a partner, create a list of controls that are often used together in a Windows Form, or sets of controls that are commonly used on multiple forms.
98-362 Windows Development Fundamentals
LESSON 2.3A
Custom Control Types
User control (or composite control) — A collection of Windows Forms controls encapsulated into one container — Inherits from the UserControl classInherited control (or extended control) — A control that derives from an existing Windows Forms control, such as a Button, TextBox, ComboBox, or RadioButton
— Retains all the functionality of the base control from which it inheritsCustom control — This term can refer to user controls or inherited controls, but it sometimes refers
to controls that inherit from the Control class. — Allows developers to create a control from scratch — Requires much more work, and also requires knowledge of the Win32
application programming interface (API)
98-362 Windows Development Fundamentals
LESSON 2.3A
Create a user control if…
You wish to combine the functionality—and graphical user interface (GUI)—of multiple existing Windows Forms controls.
Examples: A single control that includes a TextBox and the Label that identifies it. A single control that includes buttons for OK and Cancel.
98-362 Windows Development Fundamentals
LESSON 2.3A
Inherit from an existing control if…
The desired functionality is similar to an existing control.
Examples: — A TextBox that converts inputted text to a numeric data type. — A TextBox that formats numbers as currency.
You wish to design a new GUI for an existing control.
Example: — A Button with an elliptical interface instead of a rectangular interface.
Inherited controls provide an efficient way to reuse common GUI elements.
98-362 Windows Development Fundamentals
LESSON 2.3A
Inherit from an existing control if…(continued)
You wish to combine the functionality—and GUI—of multiple existing Windows Forms controls.
Examples: — A single control that includes a TextBox and the Label that identifies it — A single control that includes buttons for OK and Cancel.
Inherited controls provide an efficient way to reuse common GUI elements.
98-362 Windows Development Fundamentals
LESSON 2.3A
Inherit from the Control class if…
You wish to implement functionality that is not available in existing controls.
Example: — A control that displays a three-dimensional model that the user can rotate.
98-362 Windows Development Fundamentals
LESSON 2.3A
Creating a User Control
Follow along in Microsoft Visual Studio®.
Create a LabeledTextBox—a control that combines a TextBox with its associated Label.
98-362 Windows Development Fundamentals
LESSON 2.3A
Lesson Review
List the different types of custom controls.
Explain the uses and advantages of each type of control.
98-362 Windows Development Fundamentals
LESSON 2.3A
Lesson Review
Create a user control that combines two buttons, OK and Cancel. Add the control to two different forms within your project.