Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Starting to use Git with Visual  Studio Online 1 70
Telerik RadEditor Control Save 8 39
PowerShell: ForEach-Object Export to CSV 4 91
How do I "share" on social sites? 2 38
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:…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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