From b1e1c30abc83128bc87ae258636472c91a2937ba Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Fri, 8 Nov 2024 01:36:14 +0100 Subject: [PATCH] Revert to fix --- ChatManager/Forms/FileSelectorForm.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ChatManager/Forms/FileSelectorForm.cs b/ChatManager/Forms/FileSelectorForm.cs index f48c8dc..ce9b773 100644 --- a/ChatManager/Forms/FileSelectorForm.cs +++ b/ChatManager/Forms/FileSelectorForm.cs @@ -256,18 +256,25 @@ private void ListBoxClick(object sender, EventArgs e) // Get all CheckedListBox Controls List checkedListBoxes = GetControls(this); - // Loop all controls and get the SelectedItems from them - for (int i = 0; i < checkedListBoxes.Count; i++) + int counter = 0; + + // Loop all Controls and get the SelectedItems from them + foreach (CheckedListBox checkedListBox in checkedListBoxes) { + Logging.Write(LogEventEnum.Variable, ProgramClassEnum.FileSelectorForm, $"CheckedListBox is: {checkedListBox.Name}"); + // Check if the Controls have ANY checkedItem - if (checkedListBoxes[i].CheckedItems.Count > 0) + if (checkedListBox.CheckedItems.Count > 0) { // Set the selectedServers to the correct name - GetSelectedServers[i] = checkedListBoxes[i].Name.Substring(4); - Logging.Write(LogEventEnum.Variable, ProgramClassEnum.FileSelectorForm, $"selectedServers[{i}] is: {GetSelectedServers[i]}"); + GetSelectedServers[counter] = checkedListBox.Name.Substring(4); + Logging.Write(LogEventEnum.Variable, ProgramClassEnum.FileSelectorForm, $"selectedServers[{counter}] is: {GetSelectedServers[counter]}"); + + // Count the CheckedListBoxes + counter++; // If yes get them all - foreach (object item in checkedListBoxes[i].CheckedItems) + foreach (object item in checkedListBox.CheckedItems) { Logging.Write(LogEventEnum.Variable, ProgramClassEnum.FileSelectorForm, $"Current item is: {item}"); @@ -276,7 +283,7 @@ private void ListBoxClick(object sender, EventArgs e) GetListBoxMulti.Add(objectString); } } - else if (checkedListBoxes[i].Name == button.Tag.ToString()) + else if (checkedListBox.Name == button.Tag.ToString()) { Localization localization = new(GetSetSettings.GetCurrentLocale); ShowMessageBox.Show(localization.GetString(LocalizationEnum.MessageBoxError), localization.GetString(LocalizationEnum.Err_NoExportFileSelected));