Bosco
Bosco

Reputation:

Altering windows form from userControl

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

Upvotes: 0

Views: 224

Answers (2)

Bergmen
Bergmen

Reputation:

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.

Upvotes: 0

Rockcoder
Rockcoder

Reputation: 8479

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

Upvotes: 1

Related Questions