Building an Event Example Project

You're now going to create a very simple project in which you'll use the event procedures of a text box. Specifically, you're going to write code to display a message when a user presses a mouse button on the text box, and you'll write code to clear the text box when the user releases the button. You'll be using the e parameter to determine which button the user has pressed.

Creating the User Interface

Create a new Windows application titled Events Example. Change the form's Text property to Events Demo.

Next, add a text box to the form by double-clicking the TextBox tool in the toolbox. Set the properties of the text box as follows:

Property Value
Name txtEvents
Location 48,120
Size 193,20
Text Click Me!

Get Sams Teach Yourself C#™ in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.