I have created a Powershell Forms application which has a ComboBox in it. When running the script through Visual Studio Code, the items are correctly sorted, but after packaging as an EXE, the sort order is lost.
I have tried:
- Using $ComboBox.Sorted = $True before or after adding the items to the ComboBox
- For ($i=0; $i -le $Array.Count; $i++) {$ComboBox.Items.Add($Array[$i])}
- For ($i=$Array.Count; $i -ge 0; $i–) {$ComboBox.Items.Add($Array[$i])}
- ForEach ($Item in $Array) {$ComboBox.Items.Add($Item)}
- $Array = Get-Something | Sort-Object Name
- $Array = Get-Something | Sort-Object Name -Descending
None of the above seems to have any effect on changing the order within the EXE even though you see the changes from within VS Code.
The kicker here though is that if compile the script as an EXE through PS2EXE, the sort order is correct.
I don’t know if this is a bug, or I simply need to change the way I am using the ComboBox? Any help would be greatly appreciated.