views:

324

answers:

3

In the world of WinForms .Net controls

What is the difference between Component and Control?

Can a Control contain Components ? Can a Component contain Controls ?

+1  A: 

A Component is just a representation of an object/sub API. eg. ImageList is a component which is invisible and is just an API into a set of images. The fact you can drag and drop them onto forms is just sugar in the designer.

A Control is intended to be visible/interactable/nestable.

Program.X
There is other part of question as well.
nils_gate
A: 

In response to your comment, the Component and Control can be seen in the Object browser as being from different object hierarchies. A Component cannot be added within a Control, as the Controls collection only accepts objects with base type of Control.

A Component cannot contain Controls.

Program.X
+2  A: 

A Control has all the plumbing required to act as a window. The ability to respond to Window messages (WndProc) and having a Handle being foremost. Component is missing all that. It is really rather simple, it has design time support and it can be disposed, that's about it.

Components still can have a runtime representation, OpenFileDialog being the best example. But that is actually a dialog built into Windows, not Windows Forms.

Hans Passant