C#

Difference between Custom Controls,User controls and Components in C#.NET

Difference between Custom Controls, User controls and Components in C#: Both User control and custom control are direct or indirect derivations of Control class. Control, in turn, is derived from the component.See the derivation in below lines.

public class Component : MarshalByRefObject, IComponent, IDisposable

public class Control : Component, IDropTarget, ISynchronizeInvoke, IWin32Window,
IBindableComponent,IComponent, IDisposable

From this, it is easy to understand that the controls are much richer than components feature wise.

Components don’t have GUI like user controls or custom controls.Components are more of APIs.Examples of .NET components are Timer controls, File Browser, Data Source controls etc. A component can’t contain controls inside it.

In detail the derivation hierarchy of UserControl, Custom Control and Component  is shown below

//UserControl

public partial class UserControl1 : UserControl //UserControl1 is your control which is derived from UserControl

public class UserControl : ContainerControl

public class ContainerControl : ScrollableControl, IContainerControl

public class ScrollableControl : Control, IComponent, IDisposable

public class Control : Component, IDropTarget, ISynchronizeInvoke, IWin32Window,

IBindableComponent, IComponent, IDisposable
//CustomControl

public partial class SpecialButton : Button //SpecialButton is your custom control which is derived from Button

public class Button : ButtonBase, IButtonControl

public abstract class ButtonBase : Control

public class Control : Component, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable
//Component

public partial class YourComponent : Component  //YourComponent  is your derived from Component

public class Component : MarshalByRefObject, IComponent, IDisposable

Rajeev

Recent Posts

OWIN Authentication in .NET Core

OWIN (Open Web Interface for .NET) is an interface between web servers and web applications…

1 year ago

Serializing and Deserializing JSON using Jsonconvertor in C#

JSON (JavaScript Object Notation) is a commonly used data exchange format that facilitates data exchange…

1 year ago

What is CAP Theorem? | What is Brewer’s Theorem?

The CAP theorem is also known as Brewer's theorem. What is CAP Theorem? CAP theorem…

1 year ago

SOLID -Basic Software Design Principles

Some of the Key factors that need to consider while architecting or designing a software…

1 year ago

What is Interface Segregation Principle (ISP) in SOLID Design Principles?

The Interface Segregation Principle (ISP) is one of the SOLID principles of object-oriented design. The…

1 year ago

What is Single Responsibility Principle (SRP) in SOLID Design Priciples?

The Single Responsibility Principle (SRP), also known as the Singularity Principle, is a software design…

1 year ago