Romias
Romias

Reputation: 14133

User control added dynamically to a WinForm doesn't fire its inner controls events

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!

Upvotes: 2

Views: 2266

Answers (2)

Romias
Romias

Reputation: 14133

Problem solved.

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

Upvotes: 1

Chernikov
Chernikov

Reputation: 857

Maybe, need dynamically set event on CheckedChanged:

radioButton1.CheckedChanged += new EventHandler(radioButton1_CheckedChanged);

Upvotes: 0

Related Questions