I would like to do some processing before an item is added to a BindingList. I see there is an ListChanged event but this is fired after the item is added. The AddingNew event is only fired when the AddNew method (not the Add method) is called. Has anyone done something like this before?
UPDATE:
I have created the following classes and when the Add method is called on the IList, my new Add method gets triggered. So, do I have the casting problem that I've read in other places? If I removed the ISpecialCollection interface from the collection, my Add method doesn't get called. Can someone explain why it's acting differently? Do I have the casting problem if I use the 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());
}
}