I would like to do some processing before the item is added to the BindingList. I see that there is a ListChanged event, but it fires after adding an item. The AddingNew event is fired only when the AddNew method is called (and not the Add method). Has anyone done something like this before?
UPDATE:
I created the following classes, and when the Add method is called in IList, my new Add method starts. So, do I have a casting problem that I read elsewhere? If I remove the ISpecialCollection interface from the collection, my Add method will not be called. Can someone explain why this works differently? I have a problem with casting if I use ISpecialCollection <interface?
public interface ISpecialCollection<T> : IList<T>
{
}
public class SpecialCollection<T> : BindingList<T>, ISpecialCollection<T>
{
public new void Add (T item)
{
base.Add(item);
}
}
class Program
{
static void Main(string[] args)
{
IList<ItemType> list = new SpecialCollection<ItemType>();
list.Add(new ItemType());
}
}