Windows Forms look different in Powershell and Powershell ISE. Why?

丶灬走出姿态 提交于 2019-11-30 02:33:53

问题


I have written a script which is basically a small wysiwyg signature generator for Outlook. We want our signatures to be in corporate colours, and semi-standardised - hence the requirement for this.

I did the development work in Powershell ISE and all looked good. However, when I run the script just using powershell (as the users will) it looks totally different:

Powershell vs Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png

The top one was generated in ISE, and looks as I want it. The bottom one was run from powershell directly and seems to have visually regressed five years!

How can I get the script to look as snazzy in Powershell as it does in Powershell ISE?

Thanks,

Ben


回答1:


Add the following line in your script before you show the form:

[System.Windows.Forms.Application]::EnableVisualStyles();


来源:https://stackoverflow.com/questions/3358372/windows-forms-look-different-in-powershell-and-powershell-ise-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!