Click here to Skip to main content
15,912,977 members
Articles / Programming Languages / C#
Article

Event Control

Rate me:
Please Sign up or sign in to vote.
1.06/5 (16 votes)
25 Feb 2004 38.7K   606   15   1
How to declare and use the C# events in your application as Event Control.

Introduction

This article will explain how to declare and use the C# events in your application as Event Control. You can design your event control in couple of mints, making your event as control will be easy for GUI developers to implement events in client side.

Here are the steps:

  1. Create one Windows Application Project
  2. Add “Component Class” using "Add New Item". This is going to be your Event Control.
  3. Declare your delegate in your Event Control under your namespace.
    C#
    public delegate void SampleDelegate(string Str);
  4. Now declare your event inside your Event Control class.
    C#
    public event SampleDelegate Sample;
  5. Also add the FireTheEvent method to fire the event.
  6. Build the project.
  7. Go to Form, then ToolBox, add the Event Control using “Add/Remove Items” menu by right clicking on the tool box.
  8. Drag and drop the new control. Using the property window of the control you can easily implement the Event method in your application.
  9. Call The FireTheEvent method in your button click after adding new button to your form.
  10. Run the application and click on your button, you should see your Event firing.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalpoes Pin
Trance Junkie20-Dec-05 2:18
Trance Junkie20-Dec-05 2:18 
poes !

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.