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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelicomponentclasstopic.asp.
Implementing the IComponent interface is half of the work. You'll also need to add Visual Studio headers to your class.
See the first page of the following tutorial to get the full scoop on creating a class that can be used for data binding inside the Visual Studio designer:
I bet you could use it as a base for a custom control, but you would just have to provide the designer for it, which to me is the most difficult part of developing a custom control.
See the first page of the following tutorial to get the full scoop on creating a class that can be used for data binding inside the Visual Studio designer:
http://www.ftponline.com/vsm/2003_06/online/wagner/