Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Raise event to parent form?

Status
Not open for further replies.

codemech

Programmer
Feb 8, 2004
34
0
0
US
I have a composite user control for standard data entry operations in my Windows Forms application. Save, Delete, Add, Cancel, Find. I want the click events on these buttons to be raised to whatever form the user control is placed on. Can anyone give me some help in getting with the button click events?

~Codemech
 
public class MyClass
{
public event EventHandler SomethingHappened;

private void DoSomeWork()
{
this.SomethingHappened(this, EventArgs.Empty);
}
}



private MyClass mc1 = new MyClass();

mc1.SomethingHappened += new EventHandler(mc1_SomethingHappened);

private void mc1_SomethingHappened(object sender, EventArgs e)
{
//Do what you need to when the event occurs.
}



That should get you started.

 
Code:
private void DoSomeWork()
{
  if ( this.SomethingHappened != null )
  {
    this.SomethingHappened(this, EventArgs.Empty);
  }
}

mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top