Winforms powershell隐藏输出中的System.Windows.Forms.ListView
使用以下代码Winforms powershell隐藏输出中的System.Windows.Forms.ListView,winforms,powershell,listview,Winforms,Powershell,Listview,使用以下代码 $listView = New-Object System.Windows.Forms.ListView $listView.View = 'Details' $listView.Width = 300 $listView.Height = 300 $listView.Columns.Add('User Name') 显示索引:0 索引:0 图像索引:-1 图像列表: ImageKey: ListView:System.Windows.Forms.ListView,项。计数:0
$listView = New-Object System.Windows.Forms.ListView
$listView.View = 'Details'
$listView.Width = 300
$listView.Height = 300
$listView.Columns.Add('User Name')
显示索引:0
索引:0
图像索引:-1
图像列表:
ImageKey:
ListView:System.Windows.Forms.ListView,项。计数:0
姓名:
文本:用户名
文本对齐:左
标签:
宽度:60
地点:
容器:
它在powershell控制台中输出上述内容。
如何隐藏此输出
在任何
之前使用[void]
在-noconsole模式下使用此脚本会干扰me转换。Add
方法通常会抑制输出:
[void]$listView.Columns.Add('User Name')
要抑制输出,可以使用out null:
$listView.Columns.Add('User Name')|out-null
此外,如果将其指定给变量,则会抑制输出:
$item = $listView.Columns.Add('User Name')
$listView.Columns.Add('User Name')| out null和[void]有效谢谢