tags:

views:

22

answers:

1

Hello everyone, I use C# 2.0 & WinForm for my application. My form has 2 user controls with names: UserControl1 & UserControl2.

UserControl1 has a event CriteriaChanged:

public event CriteriaChangedHandler CriteriaChanged;
public delegate void CriteriaChangedHandler(object sender, CriteriaChangedArg e);

UserControl2 has a function:

public void Do(CriteriaChangedArg e){...}

I must use my form like as an intermediate object:

userControl1.CriteriaChanged += userControl1_CriteriaChanged;

private void userControl1_CriteriaChanged(object sender, CriteriaChangedArg e)
{
userControl2.Do(e);
}

How to create a direct call without myForm, when userControl1 raise a event CriteriaChanged, userControl1 will be called with Do() function.

Thanks.

A: 

Whats wrong with your current method? Seems pretty standard.

If you change the signature UserControl2

public void Do(object sender, CriteriaChangedArg e)

you could do this...

userControl1.CriteriaChanged += userControl2.Do;
Rohan West