views:

140

answers:

3

Hi, i'm quite new with windows forms and i have a small issue.

i have a form that contains a userControl. the form also contains a button with enabled = false, and upon some user selection in the userControl sets the button to enabled = true. basically, i want to know what's the best way to change something in the form upon a change in the userControl.

I saw on the internet that event/delegates might be the answer, but it seems too complicated for such a small thing. anyone has another solution?

thanks Bosco

+1  A: 

Events are your friends. They're really not that complicated. Just find an apropriate event for your user selection and set the button property.

Mr. Brownstone
A: 

all right, i'll take this path. thanks

A: 

User controls are meant to be hosted by different forms or other user controls. That's why they should be decoupled from their host controls.

IMHO best way to decouple the user control from its parent is to use events. Another way would be to implement the observer pattern. Events are a special implementation of observer pattern in .NET.