private void MergeButton_Click(object sender, EventArgs e) { MergedChannel dest_channel = ((MergedChannelComboBoxWrapper)DestinationChannelComboBox.SelectedItem).channel; List <MergedChannel> merge_order = new List <MergedChannel>(); foreach (object item in ChannelSortingListBox.Items) { merge_order.Add(((MergedChannelComboBoxWrapper)item).channel); } bool past_dest_channel = false; foreach (MergedChannel mc in merge_order) { if (mc == dest_channel) { past_dest_channel = true; continue; } ChannelEditing.CombineMergedChannels(dest_channel, mc, !past_dest_channel, RemoveChannelsCheckbox.Checked); } }