I have a custom collectioneditor, which i have implemented, inheriting from CollectionEditor, i want to stop adding addition items on certain conditions,

1.(Can  I pass the condition/parameter  to the CustomCollection Editor ?)

2. say i want only a defined Max(not readonly) no of items. something like onadd event..check if max..then stop.allowing.

where can i write it ..so it can stop adding items after a certain point?

i am creating a dropdown tools button like in MS office.

here is the sample code.

public class MyCollectionEditor : CollectionEditor

{

public MyCollectionEditor(Type type): base(type)

{

}

protected override Type[] CreateNewItemTypes()

{

return new Type[] { typeof(MyIconButton) };

}

 

protected override bool CanRemoveInstance(object value)

{

if (value.GetType() == typeof(MyIconButton))

return true;

else

return false;

}

protected override bool CanSelectMultipleInstances()

{

return false;

}

 

}