Powershell创建WinForm应用程序

这是一个使用PowerShell创建的WinForm应用程序示例,通过管道输入对象并显示在CheckedListBox中。用户可以选择项目,然后点击OK或Cancel按钮。当选定项被确认时,相应的对象将通过管道传递。
摘要由CSDN通过智能技术生成

Function Show-WinForm([Array]$objectArray){
#$objectArray = @($input)
#Ensure that they've piped information into the script
if($objectArray.Count -eq 0 )
{
 Write-Error "This script requires pipeline input." ;
 return
}
#load the windows Forms assembly
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");
##Create the main form
$form = New-Object Windows.Forms.Form
$form.Size  = New-Object System.Drawing.Size @(600,600);

#Create the listBox to hold the items form the pipeline
$listbox = New-Object System.Windows.Forms.CheckedListBox;
$listbox.CheckOnClick = $true
$listbox.Dock = 'Fill' ;
$form.Text = "Select the list of objects you wish to pass down the pipeline"
$listbox.Items.AddRange($objectArray);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值