Winforms Composite Controls – Custom Controls – Extended Controls


Winforms Composite Controls are controls extending from UserControl and contains other controls called as constituent controls. These constituent control are given private access hence not accessible to other assemblies.

Composite controls are simplest form and provide IDE design interface where you can drag and drop other controls.

To add composite control through visual studio you can add UserControl. Composite control can have events , properties and methods.

To let other control configure part of composite control you should expose properties to outside world. To make these controls transparent you have set back color and TransparencyKey color same. To set tool box icon you can set attribute ToolBoxBitmap to the class.

Winforms extended controls are controls inherited from existing controls. You can additional functionality by adding methods, properties and events. You can also change visual appearance original control.

public class ExtendedButton : System.Windows.Forms.Button {}

You can override methods of existing controls to provide additional functionality. To change visual appearance you have to override OnPaint method.


Leave a Reply

Your email address will not be published. Required fields are marked *