Implementing Custom Data Bindable Classes: CollectionBase
Subject:   Implementing IComponent
Date:   2003-06-12 08:45:12
From:   jamesstill
Someone wrote to me and asked if it were possible to interact with this custom collection at design time. To do it you have to turn the class into a component. It's not as hard as it sounds really. You just have to implement IComponent in addition to CollectionBase:

public class Products : CollectionBase, IComponent {

IComponent requires you to write two things, a virtual method for Dispose() and an accessor for Site. Microsoft recommends that consumers of components explicitly call Dispose() rather than leaving them to the GC to cleanup. So put a public event in the Products class for the method to call:

public event EventHandler Disposed;


public virtual void Dispose() {
if (Disposed != null)
Disposed(this, EventArgs.Empty);

You'll also have to implement the Site property and return an ISite to the caller. I won't go into that here but you can find an example on MSDN at

1 to 3 of 3
  1. Implementing IComponent
    2006-02-08 23:33:06  Linxor [View]

  2. Implementing IComponent
    2004-04-28 08:19:05  wguerra [View]

  3. Implementing IComponent
    2003-12-18 11:36:56  anonymous2 [View]

1 to 3 of 3