User Control Event Handling

  • Thread starter Thread starter Jason MacKenzie
  • Start date Start date
J

Jason MacKenzie

I have a user control (inheriting from System.Windows.Forms.UserControl)
with a button on it. I've added the control to the toolbox and have dragged
it onto a form from another project.

How can I capture the click event of the button in the parent form?
Currently nothing happens when I click the button.

Any help is appreciated,

Jay
 
One way would be to write an event in your usercontrol and fire that
event when the button in the user control is clicked.

public event EventHandler ButtonClicked;

public void button_click(object sender,EventArgs e)
{
if(Butonclicked != null)
{
Buttonclicked(sender,e);
}
}

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top