From 2cf6d47ccdb1411fc0a73b1f2fced62dbecebb6e Mon Sep 17 00:00:00 2001 From: Torsten Brendgen Date: Mon, 29 Jun 2026 17:19:30 +0200 Subject: [PATCH] Add Show-MappingTab function to manage tab selection and improve error handling --- Start-SPMigrationGUI.ps1 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Start-SPMigrationGUI.ps1 b/Start-SPMigrationGUI.ps1 index b3f570a..ede7a46 100644 --- a/Start-SPMigrationGUI.ps1 +++ b/Start-SPMigrationGUI.ps1 @@ -1047,6 +1047,29 @@ function Set-MigrationUiBusy { } } +function Show-MappingTab { + if ($null -eq $script:MainTabControl -or $null -eq $script:tabMapping) { + return + } + + if ($script:MainTabControl -isnot [System.Windows.Forms.TabControl] -or $script:tabMapping -isnot [System.Windows.Forms.TabPage]) { + return + } + + if ($null -ne $script:MainForm -and $script:MainForm.IsDisposed) { + return + } + + try { + if ($script:MainTabControl.TabPages.Contains($script:tabMapping)) { + $script:MainTabControl.SelectTab($script:tabMapping) + } + } + catch { + Write-UILog -Message ("Konnte Mapping-Tab nicht aktivieren: {0}" -f $_.Exception.Message) -Level "WARN" + } +} + function Reset-MigrationStreamPositions { $script:MigrationStreamPositions = @{ Output = [long]0 @@ -2400,7 +2423,7 @@ function Invoke-ExportFromGui { Load-MappingTableFromPath -Path $mappingPath Apply-ColumnDefaultsIfAvailable Save-MappingTableToPath -Path $mappingPath - $script:MainTabControl.SelectedTab = $script:tabMapping + Show-MappingTab } }.GetNewClosure() @@ -2798,7 +2821,7 @@ $btnLoadMapping.Add_Click({ if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { Load-MappingTableFromPath -Path $dialog.GetPath() - $script:MainTabControl.SelectedTab = $script:tabMapping + Show-MappingTab } } catch { @@ -2923,3 +2946,4 @@ if ($NoGui.IsPresent) { $formBuilder.Show() +