private void DelBtn_Click(object sender, EventArgs e) { if (LayerLB.Items.Count == 0) { return; } if (LayerLB.SelectedIndex == LayerTypes.Count - 1) { MessageBox.Show("Can't remove the output layer"); return; } LayerTypes.RemoveAt(LayerLB.SelectedIndex); LayerCounts.RemoveAt(LayerLB.SelectedIndex); LayerLB.Items.RemoveAt(LayerLB.SelectedIndex); }