Unit 1 - Programming: Lecture 10 - Event-Driven Programming Part 1
Unit 1 - Programming: Lecture 10 - Event-Driven Programming Part 1
PROGRAMMING
LECTURE 10 – EVENT-DRIVEN PROGRAMMING PART 1
TOPICS
2
GRAPHICAL USER INTERFACE (GUI)
Select
File New
Project
Windows
Application
template
Name
4
CREATING GUI APPLICATION
Design
View
Properties
Window
Form
Toolbox 5
CREATING GUI APPLICATION
Properties
Auto-hide
Solution
Explorer
Dynamic
Help
6
FORMS
Form class has many events that can be programmed as programmer wants
o Close form
o Mouse moves
o Mouse clicks (left or right)
o etc
7
FORM PROPERTIES Events
Alphabetical
Categorized
Property value
Properties
8
FORM PROPERTIES
9
FORM METHODS
Many events can happen on a Form object: key board pressed, mouse clicked, mouse
moved, etc.
When an event happens, system will call a specific method for that event to response
to it
Event-driven programming:
o Event is the key. Logic of program is represented by events
o Programmer select event that is useful for program to implement (not all)
11
FORM EVENTS
Click to
view the
list of
Form’s
events
12
EVENT HANDLER
Controls are:
o Button, Label, TextBox, ComboBox, MainMenu, ListBox, CheckBox,
RadioButton, and MonthCalendar, etc.
14
SUB CLASSES OF CONTROL object
object
• They are:
object
• System.Windows.Forms.Label
• System.Windows.Forms.TextBox object
• System.Windows.Forms.Button
object
• V.v. object
16
CONTROLS
EXAMPLES
17
ADD CONTROLS ON FORM (VISUAL
PROGRAMMING)
From Toolbox, select and drag necessary control to Form
Controls alignment
o Aligned
o Same size
o Etc.
18
COMMON PROPERTIES OF CONTROLS
19
COMMON METHOD CONTROLS
20
CONTROLS
EXAMPLE
21
LABELS
• Showing texts
• Naming other controls
• Showing texts that user cannot change
• Important properties
– Text: content to show
– Font: font of text
– BackColor, ForeColor: background color and text color
COMMAND BUTTONS
26