protected override void OnControlRemoved(ControlEventArgs e) { base.OnControlRemoved(e); TileIcon newItem = e.Control as TileIcon; if (newItem != null) { newItem.MouseWheel -= new MouseEventHandler(newItem_MouseWheel); } if (!this.VerticalScroll.Visible) { foreach (var item in this.Controls.OfType <TileIcon>()) { item.Width = this.Width - this.Padding.Left - this.Padding.Right; } } }
protected override void OnControlAdded(ControlEventArgs e) { base.OnControlAdded(e); TileIcon newItem = e.Control as TileIcon; if (newItem == null) { this.Controls.Remove(newItem); return; } newItem.Width = this.Width - this.Padding.Left - this.Padding.Right; newItem.Dock = DockStyle.Top; newItem.MouseWheel += new MouseEventHandler(newItem_MouseWheel); if (this.VerticalScroll.Maximum > this.Height) { foreach (var item in this.Controls.OfType <TileIcon>()) { item.Width = this.Width - this.Padding.Left - this.Padding.Right - 20; } } }