CHTP5e_09-Programming and Interfacing
CHTP5e_09-Programming and Interfacing
Structures
• Introduction
• Classes, objects, and methods
• Graphical user interface
1.Introduction
• Methods
– The method describes the mechanisms that actually
perform its tasks.
– The method hides from its user the complex tasks that it
performs.
2. Classes, methods
• Classes
– In C#, we begin by creating an app unit called a class to
house (among other things) a method.
– In a class, you provide one or more methods that are
designed to perform the class’s tasks.
• Example
– a class that represents a bank account might contain one
method to deposit money in an account, another to
withdraw money from an account and a third to inquire
what the current account balance is.
2. Classes, methods
• Objects
– Just as you cannot drive an engineering drawing of a car,
you cannot “drive” a class.
– Just as someone has to build a car from its engineering
drawings before you can actually drive it, you must build
an object of a class before you can make an app perform
the tasks the class describes.
3. Graphical user interface
• Example:
– The user enters text into a password box and clicks the
Button, causing the text input to be displayed in the Label.
3.4. Labels, Textboxes and Button
3.5. Groupboxes and panels
• Example:
– uses a GroupBox and a Panel to arrange Buttons.
– When these Buttons are clicked, their event handlers
change the text on a Label.
3.5. Groupboxes and panels
3.5. Groupboxes and panels
3.6. Checkboxes and Radio button
• Checkboxes
– A Check Box is a small square that either is blank or
contains a check mark.
– You can also configure a CheckBox to toggle between
three states (checked, unchecked and indeterminate) by
setting its Three State property to true.
3.6. Checkboxes and Radio button
3.6. Checkboxes and Radio button
• Example
– allows the user to select CheckBoxes to change a Label’s
font style.
3.6. Checkboxes and Radio button
3.6. Checkboxes and Radio button
3.6. Checkboxes and Radio button
• Radio buttons
– Radio buttons (defined with class RadioButton) are similar
to CheckBoxes in that they also have two states—selected
and not selected.
– However, Radio Buttons normally appear as a group, in
which only one RadioButton can be selected at a time.
3.6. Checkboxes and Radio button
• Example
• Using radio button