2

I have a Control, within a control, within a control.

Like so..

QuizMaster -> Question -> Answers -> RadioButton

When one of the answers is checked I want the function in Quizmaster called AskNextQuestion() to run.

How do I do that?

Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84

1 Answers1

1

You would create an event in your nested control, and have your QuizMaster subscribe to that event.

In your Answers add this:

public static event Action<bool> IsAnswered;

and Fire this event when you select a RadioButton in its handler

public void OnRadioButtonSelected(object sender, SomeEventArgs e)
{
  if(IsAnswered != null)
    IsAnswered(true);
}

and in your QuizMaster Subscribe to this static event:

public void SomeMethod()
{
  Answers.IsAnswered += new Action<bool>(Answers_IsAnsweredCompleted);
}

public void Answers_IsAnsweredCompleted(bool IsAsnwered)
{
  //call your method in QuizMaster
}
VoodooChild
  • 9,776
  • 8
  • 66
  • 99