internal void UpdateItems()
{
if (this.Items.Count == this.Controls.Count)
{
// make sure the the items index in the ControlCollection
// are the same as in the ItemCollection (indexes in the
// ItemCollection may have changed due to the user moving
// them around in the editor)
this.MatchControlCollToItemColl();
return;
}
// were any items added
if (this.Items.Count > this.Controls.Count)
{
// add any extra items in the ItemCollection to the
// ControlCollection
for (int i=0; i<this.Items.Count; i++)
{
if (!this.Controls.Contains(this.Items[i]))
{
this.OnItemAdded(new ControlEventArgs(this.Items[i]));
}
}
}
else
{
// items were removed
int i = 0;
Control control;
// remove any extra items from the ControlCollection
while (i < this.Controls.Count)
{
control = (Control) this.Controls[i];
if (!this.Items.Contains(control))
{
this.OnItemRemoved(new ControlEventArgs(control));
}
else
{
i++;
}
}
}
this.Invalidate(true);
}