Lecture 12 P3 - STD - Events and Event Parameters in C Sharp
Lecture 12 P3 - STD - Events and Event Parameters in C Sharp
1
CREATE A C# WINDOWS APPLICATIONS
• Select Windows Forms Application or Windows Forms App. Keep the Name on the
default of WindowsFormsApp1 and then click Next.
2
CREATE A C# WINDOWS APPLICATIONS
4
• Windows Application
project is created.
• Notice the Toolbox,
though, on the left hand
side. We'll be adding
controls from the Toolbox
to that blank Form1 you
can see in the image above.
5
ADDING CONTROLS TO A FORM
ADDING CONTROLS TO A FORM
EVENTS AND EVENT
PARAMETERS IN C SHARP
& HIDING AND SHOWING
FORMS IN C SHARP
C# EVENT HANDLING FOR CONTROLS
• When working with windows form, you can add events to controls.
• An event is something that happens when an action is performed.
• Probably the most common action is the clicking of a button on a form.
• In C# Windows Forms, you can add code which can be used to perform certain
actions when a button is pressed on the form.
C# EVENT HANDLING FOR CONTROLS
• What we want to do now is to display a message box whenever the button is
clicked.
• To see the code for the button, double click the button you added to the Form, or
right click on the button then select view code.
C# EVENT
HANDLING FOR
• TheCONTROLS
coding window will open, and your
cursor will be flashing inside of the button
code. It will look like this:
C# EVENT HANDLING FOR CONTROLS
C# Messagebox
C# EVENT HANDLING FOR CONTROLS
C# Message Box
Get user input – Selected Item
Tree and Picture Box Control
• There are 2 further controls, one is the ‘Tree Control’ and the other is the ‘Image
control’.
Tree Control
• The tree control is used to list down items in a tree like fashion. Probably the best
example is when we see the Windows Explorer itself. The folder structure in
Windows Explorer is like a tree-like structure.
C# EVENT HANDLING FOR CONTROLS
Implement a Tree Control
C# EVENT HANDLING FOR
CONTROLS
Picture Box Control
C# WINDOWS APPLICATIONS
QUESTIONS?
Let’s take a break!
C# EVENT HANDLING FOR CONTROLS
Exercise
QUESTIONS?