Solved

How do I add an event to a user created partial class?

Posted on 2009-05-12
2
201 Views
Last Modified: 2013-12-17
In C #, I generated a partial class of a windows form. I placed the event handlers in the user created partial class. VS usually adds the event handler in a created partial class that contains the constructor. I would like to know how i should add the event handler to the event of the button seeing as its not possible using the properties tab.

I hope my question is clear
0
Comment
Question by:SarahAm
2 Comments
 
LVL 3

Accepted Solution

by:
demi-os earned 250 total points
ID: 24372209
to add an event from the form to another class you can do:
     
private void Form1_Load(object sender, EventArgs e)
{
            SomeClass sc = new SomeClass();
            button1.Click += new EventHandler(sc.button1_click);
 }

where SomeClass is something like this:
    class SomeClass
    {
        public void button1_click(object sender, EventArgs e)
        {
            MessageBox.Show("button1 click");
        }
    }
0
 

Author Closing Comment

by:SarahAm
ID: 31580860
Thank You
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now