37

What is the difference between a Control and a UserControl in .NET WinForms? I want to create a custom control, but which one should I inherit from? I've always used Control in the past without any issues, but is the "recommended" way of creating a custom control?

Jon Tackabury
  • 47,710
  • 52
  • 130
  • 168

1 Answers1

51

Here is a good article about this question. user controls

However in short

A Control is either inherited or completely custom. You write and handle many of the events yourself. You can even control how and when the control is drawn thru the use of GDI+ drawing.

A UserControl is a collection of controls placed together to be used in a certain way. For example you can place a GroupBox that contains Textbox’s, Checkboxes, etc. This is useful when you have to place the same group of controls on/in multiple forms or tabs. Note: you can write some custom events and drawing for UserControls also.

Billy
  • 2,600
  • 6
  • 31
  • 36
  • Thanks - I searched but didn't see any questions that looked like a comparison of the 2 types. – Jon Tackabury May 28 '09 at 15:37
  • 2
    [This page](http://msdn.microsoft.com/en-us/library/ms171725.aspx) on the MSDN also describes the different kinds of custom controls and the reasons for choosing each one. – Steven Doggart Jun 18 '14 at 15:20