Assuming the instance of Form4 has a valid reference to the instance of Form6:
public Action DefectButtonPressed;
private void `BtnAdd_Click(object sender, EventArgs e)
{
if (DefectButtonPressed != null) DefectButtonPressed();
}
instanceOfForm6.DefectButtonPressed += OnDefectButtonPressed;
private void OnDefectButtonPressed()
{
}
If both Form4 and Form6 are created by some other Form, do the right thing so Form4 has a reference to Form6.
This type of "code injection" keeps the dependency between the two Forms minimal; there will be no error thrown if the Action is not defined when the button on Form6 is clicked.
'Action is a Delegate; it can have multiple subscribers: [
^]