protected override void OnControlAdded(ControlEventArgs e)
{
// check if control is a MozItem
if ((e.Control as MozItem) == null)
{
// If not remove and...
this.Controls.Remove(e.Control);
// throw exception
throw new InvalidCastException("Only MozItem's can be added to the MozPane");
}
base.OnControlAdded(e);
// Check if item exists in collection
if (!this.Items.Contains((MozItem) e.Control))
{
// if not add it
this.Items.Add((MozItem) e.Control);
}
// Refresh
Invalidate();
}