?
Solved

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

Posted on 2009-05-12
2
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
demi-os earned 750 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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:…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

770 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