public void Remove(string name) { //Grab which control is being removed UIListBoxItem c = (UIListBoxItem)flpListBox.Controls[name]; flpListBox.Controls.Remove(c); //Remove the event hook c.SelectionChanged -= SelectionChanged; c.Click -= ItemClicked; c.DoubleClick -= ItemDoubleClicked; //Now dispose of properly c.Dispose(); SetupAnchors(); }
public void Clear() { do { if (flpListBox.Controls.Count == 0) { break; } UIListBoxItem c = (UIListBoxItem)flpListBox.Controls[0]; flpListBox.Controls.Remove(c); //Remove the event hook c.SelectionChanged -= SelectionChanged; c.Click -= ItemClicked; c.DoubleClick -= ItemDoubleClicked; //Now dispose of properly c.Dispose(); }while (true); LastSelectedItem = null; }