powershell - winform displaying in classic view outside of ISE -


not sure causing issue have powershell script uses windows forms ui. when developing inside of powershell ise looked nice modern style buttons. when run powershell displays in windows classic style view , crashes when make call new-object system.windows.forms.savefiledialog. there fix can add code script not looks better functions outside of ise?

edit: function call savefiledialog. works inside of ise when run script powershell crashes when call this.

function exporttocsv([system.object[]] $exparray) {     $save = new-object system.windows.forms.savefiledialog     $save.createprompt = $false     $save.supportmultidottedextensions = $true     $save.defaultext = "csv"     $save.filter = "csv (*.csv) | *.csv*"     $save.title = "export csv"     if ($save.showdialog() -eq "ok") {         $exparray | export-csv $save.filename     } } 

include following command in script before showing form modern style appearance.

[system.windows.forms.application]::enablevisualstyles() 

this should not affect savefiledialog. i'm gonna need more since you're saying works in ise, not in normal console.

a workaround savefiledialog adding:

$save.showhelp = $true 

in ps3.0 works fine, in ps2.0 dialog doesn't show. showhelp fixes that, gives old-style dialog. however, functionality more imporant appearance. :)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -