powershell winform

cls
function HelloWord{
  [System.Windows.Forms.MessageBox]::Show("Hello world!")
}


[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$app=[System.Windows.Forms.Application];

$myForm=new-object System.Windows.Forms.Form;
$myForm.Text="my window";

$button1 = new-object System.Windows.Forms.Button;
$button1.Size = new-object System.Drawing.Size  -argumentlist 75, 23;
$button1.Text = "点我试试";

$textbox1=new-object System.Windows.Forms.TextBox;
$textBox1.Multiline = $true;
$textBox1.Text = "hello world";
$textBox1.Size = new-object System.Drawing.Size  -argumentlist 281, 227;

$flowLayoutPanel1 = new-object System.Windows.Forms.FlowLayoutPanel;
$myForm.Controls.Add($flowLayoutPanel1)
$flowLayoutPanel1.Controls.Add($textBox1);
$flowLayoutPanel1.Controls.Add($button1);
$flowLayoutPanel1.Dock = "Fill";
$flowLayoutPanel1.FlowDirection = "TopDown";
$button1ClickEventHandler = [System.EventHandler] {
param
 (
       [Object] $sender,
       [EventArgs] $e
    )
    [System.Windows.Forms.MessageBox]::Show("Hello world!");
}

#$button1.Add_Click($button1ClickEventHandler);

$button1.Add_Click({HelloWord});

#$button1.Add_Click(
#{
#[System.Windows.Forms.MessageBox]::Show("Hello world!");
#}
#);

$app::EnableVisualStyles()
$app::Run($myForm)

 

posted on 2010-12-16 16:25 沙漠鱼 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/zhaojun20002003/archive/2010/12/16/1908353.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值