System.ComponentModel namespace usage

867 views Asked by At

I consider myself a reasonably experienced .NET developer but I have almost never directly used types in the System.ComponentModel namespace. (I've implemented a few custom attributes and consumed them via reflection).

In what sort of scenarios do types such as Component, Container, PropertyDescriptor, TypeDescriptor, License and TypeConverter come in most useful?

I've often seen System.ComponentModel mentioned when talking about "designers" such as those available in Visual Studio.

Are these types only useful when you, for example, want to build a custom control with nice visual designer (eg. custom properties etc)? Or could I also be using them in more general code?

1

There are 1 answers

2
Dave Mateer On

Like you, I've only used the specific classes you list (Component, Container, etc.) indirectly, i.e. in already-derived form (every System.Windows.Forms.Control derives from Component, etc.). So I don't have anything more to add there. When adding properties to custom controls, I almost always use many of the DefaultValueAttribute, DesignerSerializationVisibilityAttribute, and other *Attribute classes. But that's pretty common, and probably not what your question was after.

As far as the rest of the namespace, I have need for a lot of asynchronous processing, and make frequent use of the following:

  • AsyncOperation
  • AsyncOperationManager
  • ProgressChangedEventHandler / ProgressChangedEventArgs
  • RunWorkerCompletedEventHandler / RunWorkerCompletedEventArgs