简体   繁体   English

PowerShell 中的 Out-GridView:如何更改窗口的初始大小?

[英]Out-GridView in PowerShell: How to change the initial size of the window?

I often work with the useful function Out-GridView in PowerShell.我经常在 PowerShell 中使用有用的函数 Out-GridView。 Sometimes I only have little data to show in the GridView but it opens in a very big window every time.有时我在 GridView 中只显示很少的数据,但它每次都会在一个非常大的窗口中打开。 Is there a possibility to change the initial size of the GridView window?是否有可能更改 GridView 窗口的初始大小? A table with 3 columns and 4 rows should not be displayed in a window that is nearly fullscreen on a 1920x1080 display ...不应在 1920x1080 显示器上几乎全屏的窗口中显示具有 3 列和 4 行的表格...

PowerShell is a scripting language, not really a GUI language. PowerShell 是一种脚本语言,而不是真正的 GUI 语言。 It's possible to create GUI's with the help of tools like SAPIEN PowerShell Studio and others, by using Winforms or wpf.通过使用 Winforms 或 wpf,可以在 SAPIEN PowerShell Studio 等工具的帮助下创建 GUI。

In short, what you want is not possible I'm afraid, as there's no parameter for it.简而言之,恐怕你想要的是不可能的,因为它没有参数

I ran into the same issue and ended up using this "workaround" that autosizes.我遇到了同样的问题,最终使用了这种自动调整大小的“解决方法”。

$null = [System.Reflection.Assembly]::LoadFile('C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Microsoft.VisualBasic.dll')

$words = @"
    Line 1
    This is the line after line 1
    The third line contains the number 5.
"@

#if "words" is an array, change below to ($words | out-string)

[Microsoft.VisualBasic.Interaction]::MsgBox(($words),0, "Title")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM