views:

939

answers:

2

I have a user control which has several radiobuttons and buttons... I have code to handle button's click events and radio button's CheckedChange event.

After adding this userControl dynamically to a Form panel, I notice the events of the inner controls are not firing.

I'm doing a "new" of the user control, and adding it to the Controls collection of the Panel. I'm also calling the "Show" method of the user control.

The LoadEvent of the user control is called... and if I programatically check one of the radio buttons from the OnLoad event handler... the CheckedChange events fires... but if I do it "with the mouse" it doesn't work.

Do you have any idea why the events of the inner controls are not firing?

Thanks in advance!

A: 

Maybe, need dynamically set event on CheckedChanged:

radioButton1.CheckedChanged += new EventHandler(radioButton1_CheckedChanged);
Chernikov
mmm... the usercontrol is created dinamically... but the controls of it are created at design time.
Romias
Where need to catch events from radiobuttons? If inside UserControl - check that events are binded. If on main form (panel), create event for main form (userControl.radioButton.CheckedChanged += new EventHandler(there method of main form);
Chernikov
The UserControl is a Wizard Step, so when the user change the RadioButton selected I need to handle that IN the usercontrol and set a property to be consumed by the main form later.
Romias
A: 

Problem solved.

In my usercontrol's Constructor I found a DOUBLE call to the InitializeComponent()... It was a copy paste error.

Romias
Please mark this as "the answer" so it doesn't show in the "Unanswered" section...
awe
Sorry... it didn't allow me in that moment and then I forget.
Romias