private void Modlist_ItemCheck(object sender, ItemCheckEventArgs e) { if (!ReadyForRefresh) { return; } if (Modlist.Items[e.Index] is ModRelay && (Modlist.Items[e.Index] as ModRelay).MyType == ModRelay.ModType.Invalid && e.NewValue == CheckState.Checked) { //e.NewValue = CheckState.Unchecked; if (inp == null || inp.IsDisposed) { inp = new InvalidModPopup(this, (Modlist.Items[e.Index] as ModRelay).AssociatedModData.DisplayedName); } inp.ShowDialog(); } CheckState[] ich = new CheckState[Modlist.Items.Count]; for (int i = 0; i < ich.Length; i++) { ich[i] = Modlist.GetItemCheckState(i); } ich[e.Index] = e.NewValue; Wood.WriteLine("Mod state about to change: " + (Modlist.Items[e.Index] as ModRelay).AssociatedModData.DisplayedName + "; Type: " + (Modlist.Items[e.Index] as ModRelay).MyType.ToString()); ApplyModlist(ich); Wood.WriteLine("Resulting state: " + ((Modlist.Items[e.Index] as ModRelay).enabled ? "ON" : "OFF")); }