Chapter 13: Handling Events

Similar documents
Events. Event Handler Arguments 12/12/2017. EEE-425 Programming Languages (2016) 1

Overview Describe the structure of a Windows Forms application Introduce deployment over networks

Understanding Events in C#

More Language Features and Windows Forms

More Language Features and Windows Forms. Part I. Some Language Features. Inheritance. Inheritance. Inheritance. Inheritance.

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

Event-based Programming

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.

Skinning Manual v1.0. Skinning Example

Quick Guide for the ServoWorks.NET API 2010/7/13

Your First Windows Form

CST242 Windows Forms with C# Page 1

Use Web Event Bubbling

02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211

Philadelphia University Faculty of Information Technology. Visual Programming

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

MenuStrip Control. The MenuStrip control represents the container for the menu structure.

C# Forms and Events. Evolution of GUIs. Macintosh VT Datavetenskap, Karlstads universitet 1

CALCULATOR APPLICATION

Spring 2009 Wilson Scholar Application. Designing and Analyzing New Algorithms and Heuristics to Solve the Coin-Moving Puzzle

Responding to the Mouse

MDA Custom Map Control Creation for GPS View V1.1 Tutorial

CIS2052 Advanced Programming I [C# Programming Language]

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Agenda. First Example 24/09/2009 INTRODUCTION TO VBA PROGRAMMING. First Example. The world s simplest calculator...

Module 201 Object Oriented Programming Lecture 10 - Arrays. Len Shand

CPSC Tutorial 6

Chapter 14. Exception Handling and Event Handling

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Platform SDK Developer's Guide. Management Layer

Life After Webmail Reference Guide

How to create a simple ASP.NET page to create/search data on baan using baan logic from the BOBS client sample.

Menus and Printing. Menus. A focal point of most Windows applications

10Tec igrid for.net 6.0 What's New in the Release

Developing for Mobile Devices Lab (Part 1 of 2)

CPSC Tutorial 5

The original of this document was developed by the Microsoft special interest group. We made some addons.

CST141 JavaFX Events and Animation Page 1

Routing a BennyBuy Access Form Using DocuSign

CIS 3260 Intro. to Programming with C#

The Observer Pattern

Microsoft Dynamics AX This document describes the concept of events and how they can be used in Microsoft Dynamics AX.

event driven programming user input Week 2 : c. JavaFX user input Programming of Interactive Systems

CS 160: Interactive Programming

Threads are lightweight processes responsible for multitasking within a single application.

HOUR 4 Understanding Events

Event Driven Programming

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

By: Computer Education. Introduction Level One

IBSDK Quick Start Tutorial for C# 2010

Training Guide. Microsoft Excel 2010 Advanced 1 Using Conditional and Custom Formats. Applying Conditional Formatting

private void closetoolstripmenuitem_click(object sender, EventArgs e) { this.close(); }

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations

Postback. ASP.NET Event Model 55

CST272 Getting Started Page 1

Form Properties Window

How to set up an Amazon Work Profile for Windows 8

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

//filename.cs using System; using System.Windows.Forms; [STAThread] public static void Main() { Application.Run(new Form1()); } }

Class Test 5. Create a simple paint program that conforms to the following requirements.

Blank Form. Industrial Programming. Discussion. First Form Code. Lecture 8: C# GUI Development

Philadelphia University Faculty of Information Technology. Visual Programming. Using C# -Work Sheets-

Visual Basic Program Coding STEP 2

and event handlers Murach's C# 2012, C6 2013, Mike Murach & Associates, Inc. Slide 1

Outlook 2003 Tips, Tricks for Managing Your

Chapter 13. Custom Events. Learning Objectives

EUSurvey 1.4 Editor Guide

CH3: C# Programming Basics BUILD YOUR OWN ASP.NET 4 WEB SITE USING C# & VB

We assume that the user has basic knowledge of C# and is able to create a new C# project.

Unit A451: Computer systems and programming. Section 3: Software 1 Intro to software

Visual Programming (761220) First Exam First Semester of Date: I Time: 60 minutes

Porting your Dyalog Application to Internet

EL-USB-RT API Guide V1.0

CT862 Section 1 Introduction

Computer Architecture Review CS 595

INCA V7.0 Instrument Integration Development Kit. Tutorial

CSC 211 Intermediate Programming

Creating Screen Shots and Using Textboxes to Add Information and De-Identify Data for Patient-Centered Medical Home (PCMH) Documentation

More About Objects and Methods

CPSC Tutorial 5 WPF Applications

Client Portal User Guide. December 4, 2012

Instructions for writing Web Services using Microsoft.NET:

2. Click New in the upper left corner of the standard toolbar (along the top) to open a new message box.

Lesson 1: Getting Started with

Menus. You ll find MenuStrip listed in the Toolbox. Drag one to your form. Where it says Type Here, type Weather. Then you ll see this:

The Network. Multithreading. This tutorial can be found on -

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

1. Download the files VFE2.03GTM.ova and CPRSSetupV1.0.6.exe from the following site:

Chapter 6 Dialogs. Creating a Dialog Style Form

Microsoft Office Outlook 101

MICROSOFT OFFICE OUTLOOK 101

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018

Software Architecture

INFORMATICS LABORATORY WORK #4

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

1. Move your mouse to the location you wish text to appear in the document. 2. Click the mouse. The insertion point appears.

Address Bar. Application. The space provided on a web browser that shows the addresses of websites.

Chapter 13 Working with Threads

Transcription:

Chapter 13: Handling Events

Event Handling Event Occurs when something interesting happens to an object Used to notify a client program when something happens to a class object the program is using Event driven An event drives the program to perform a task Events can be raised, fired, or triggered Event handler A method that performs a task in response to an event 2

Event Handling (cont d.) 3

Event Handling (cont d.) private void button1_click(object sender,eventargs e) { label1.text=sender.tostring(); } 4

Event Handling (cont d.) private void button1_click(object sender,eventargs e) { label1.text=e.tostring(); } 5

Event Handling (cont d.) Event handler (cont d.) Conventionally named using: The identifier of the Control An underscore The name of the event Example: changebutton_click() Also known as an event receiver Event sender A Control that generates an event 6

Event Handling (cont d.) Event handler example: private void changebutton_click(object sender, EventArgs e) { } hellolabel.text = e.tostring(); EventArgs A C# class designed for holding event information Click event Generated when a Button object is clicked 7

Using the Built-in Event Handler The.NET Framework provides guidelines an event takes two parameters: The source of the event The EventArgs parameter 8

Handling Control Component Events Existing Control components already have events with names See Table 13-1 9

Handling Control Component Events (cont d.) 10

Handling Control Component Events (continued) (cont d.) 11

Handling Control Component Events (cont d.) (continued) 12

Handling Control Component Events (cont d.) You have already used the IDE to create some eventhandling methods The default events generated for a Control in the IDE Using the Events icon in the Properties window The IDE saves you time by automatically entering the needed statement correctly 13

Handling Control Component Events (cont d.) 14

Handling Control Component Events (cont d.) 15

Handling Mouse Events Mouse events Actions a user takes with a mouse Including clicking, pointing, and dragging Handled through an object of the class MouseEventArgs 16

Handling Mouse Events (cont d.) 17

Handling Mouse Events (cont d.) 18

Handling Mouse Events (cont d.) 19

Handling Mouse Events (cont d.) 20

Handling Keyboard Events Key events Keyboard events Occur when the user presses and releases keyboard keys KeyEventHandler and KeyPressEventHandler KeyEventArgs and KeyPressEventArgs Classes used to handle key events 21

Handling Keyboard Events (cont d.) 22

Handling Keyboard Events (cont d.) 23

Handling Keyboard Events (cont d.) 24

Handling Keyboard Events (cont d.) 25

Managing Multiple Controls When Forms contain multiple Controls, you often want several actions to have a single consequence 26

Handling Multiple Events with a Single Handler You can associate the same event with multiple Controls Use the Events icons in the Properties window Displays all the existing events that have the correct signature to be the event handler for the event 27

Managing Multiple Controls 28