1. Home
  2. Computing & Technology
  3. Visual Basic
Dan Mabbutt
Dan's Visual Basic Blog

By Dan Mabbutt, About.com Guide to Visual Basic

What's the difference between a control and a component?

Saturday October 3, 2009

These two terms are often used interchangeably in articles that you might see. Here's an example from Wikipedia:

"ASP.NET supports creating reusable components through the creation of User controls."

Which is it? A control or a component. I can't tell.

Here's my definition. A "component" is a generic term that means just what the dictionary says it means: "a part of something". It doesn't really have a technical definition. A "control", however, is a specific thing, but most sites define it the way it was in VB6, that is an "ActiveX Control". VB.NET can use those controls by wrapping them in managed code (ActiveX Controls are called "COM Components" in the Visual Studio tooltip displayed for them.), but VB.NET also has controls that are .NET managed classes. VB.NET is a little more consistent in that usually when something is called a "component" it means that it doesn't have a user interface. Everything in the Components tab (like Timer) is only visible at the bottom of the design window in Visual Studio (an area called the "component tray").

Comments
October 5, 2009 at 2:44 am
(1) John McIlhinney says:

As with many things, the “official” definition of the terms depends on your frame of reference. If you’re working in WinForms, a component is any class that implements the IComponent interface. That is the requirement for a class to be able to appear in the VS Toolbox. Generally we don’t implement IComponent ourselves but rather inherit the Component class.

A control is any class that inherits, either directly or indirectly, the Control class. The Control class itself inherits the Component class. As such, every control is a component, so it can appear in the VS Toolbox.

Generally speaking a component is a class that can be designed, i.e. visually manipulated in a VS designer, and a control is a component that provides a user interface. Note that a typed DataSet can be designed because it is a component, but it has no UI so it’s not a control. This is not a hard-and-fast rule though so, if in doubt, simply consult the documentation and check the inheritance hierarchy for the class.

As I said, this is the official definition for WinForms. The same cannot be said for ASP.NET or WPF.

October 5, 2009 at 10:55 am
(2) Dan Mabbutt says:

I’m starting to depend on John to help clarify issues involving terminology. See his contributions HERE and HERE for example. John is a reliably critical thinker. Good Stuff!!

I certainly agree with John’s first statement. It does depend on your frame of reference. Some About Visual Basic readers are still using VB6 and none of this applies in that frame of reference. But if you’re a VB.NET programmer, John is technically right on target.

My original point, however, is that the use of these terms is typically all over the map. Sometimes using technically accurate terminology is critical beccause you miss the real significance if you don’t understand it. But sometimes it’s not so important. Since most people seem to swap these two terms around with reckless abandon, this is one of those cases where it’s usually not critical.

October 5, 2009 at 7:50 pm
(3) John McIlhinney says:

“John is a reliably critical thinker. Good Stuff!”

Nah. Just a bit anal when it comes to terminology. ;-)

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Visual Basic
By Category
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2010 About.com, a part of The New York Times Company.

All rights reserved.