diff --git a/PKHeX.WinForms/Subforms/SAV_FolderList.cs b/PKHeX.WinForms/Subforms/SAV_FolderList.cs index 6c7d60df0..897c028af 100644 --- a/PKHeX.WinForms/Subforms/SAV_FolderList.cs +++ b/PKHeX.WinForms/Subforms/SAV_FolderList.cs @@ -51,8 +51,10 @@ public SAV_FolderList(Action openSaveFile) for (int i = 0; i < TempTranslationLabels.Count; i++) { var text = TempTranslationLabels[i].Text; - dgDataRecent.Columns[i].HeaderText = text; - dgDataBackup.Columns[i].HeaderText = text; + if (i < dgDataRecent.ColumnCount) + dgDataRecent.Columns[i].HeaderText = text; + if (i < dgDataBackup.ColumnCount) + dgDataBackup.Columns[i].HeaderText = text; CB_FilterColumn.Items[i+1] = text; } @@ -173,7 +175,15 @@ public CustomFolderPath(string path, string display) private string GetParentFolderName(SaveFile first) { var parent = Paths.Find(z => first.FileFolder.StartsWith(z.Path)); - return parent?.DisplayText ?? "???"; + if (parent != null) + return parent.DisplayText; + + // likely an autodetect location; try to get a decent filename + var backups = PathUtilWindows.GetFoldersToCheck(Enumerable.Empty()); + var path = backups.FirstOrDefault(z => first.FilePath.StartsWith(z)); + if (path == null) + return "???"; + return Directory.GetParent(path).Name; // trim off the first subfolder of the autodetect location } private sealed class SaveList : SortableBindingList { } @@ -344,6 +354,8 @@ private void SetRowFilter() private void GetFilterText(DataGridView dg) { + if (dg.RowCount == 0) + return; var cm = (CurrencyManager)BindingContext[dg.DataSource]; cm.SuspendBinding(); int column = CB_FilterColumn.SelectedIndex - 1; diff --git a/PKHeX.WinForms/Util/PathUtilWindows.cs b/PKHeX.WinForms/Util/PathUtilWindows.cs index c7cd88527..30bff7a72 100644 --- a/PKHeX.WinForms/Util/PathUtilWindows.cs +++ b/PKHeX.WinForms/Util/PathUtilWindows.cs @@ -114,7 +114,7 @@ public static IEnumerable GetSaveFiles(IEnumerable extra) return byMostRecent.Select(SaveUtil.GetVariantSAV); } - private static IEnumerable GetFoldersToCheck(IEnumerable extra) + public static IEnumerable GetFoldersToCheck(IEnumerable extra) { var foldersToCheck = extra.Where(f => f?.Length > 0);