0
votes

In a Windows Form application I have a Form with a UserControl that contains a child control. I have an event handler for the child control's Validating event. On the parent UserControl I call the ValidateChildren() method. But the event handler for the child control's Validating event does not run. The CausesValidation property is set to true on both the parent UserControl and the child control. Is there any reason why the Validating event handler would not run?

The child control is a custom control derived from Panel. It contains two RadioButton controls, both of which have their CausesValidation property set to true.

1
No repro. You need to post a sample project that exhibits this problem on a file sharing service. - Hans Passant

1 Answers

3
votes

I think I figured it out. The control was not raising the Validating event because it was not selectable. A Panel control is not by default selectable nor are controls derived from Panel (See link text). So in the UserControl's constructor I called SetStyle(ControlStyles.Selectable, true);. Now it raises the Validating event.