private void RemoveButton_Click(object sender, EventArgs e) { if (FileListBox.Items.Count > 0) { var newList = new List <string>(); for (var index = 0; index < FileListBox.Items.Count; index++) { if (!FileListBox.GetItemChecked(index)) { newList.Add(FileListBox.Items[index].ToString()); } } FileListBox.Items.Clear(); foreach (var item in newList) { FileListBox.Items.Add(item); } if (FileListBox.Items.Count > 0) { SelectMode = !SelectMode; } else { SelectMode = true; } } }