Solved

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

Posted on 2009-05-12
2
204 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

14 Experts available now in Live!

Get 1:1 Help Now