我正在尝试创建 8 个标签,并编辑它们的 .Text 属性。
我已经搜索了一段时间,但在网上找不到任何东西。不过,我可能会错误地搜索到这一点。
这是我正在尝试做的事情的示例:
for ($i=1; $i -le 8; $i++)
{
New-Object -TypeName System.Windows.Forms.Label | New-Variable -name "testing$i"
$testing$($i).Text = 'text of label'
}
我觉得我已经很接近了,但我已经没有想法了。我想知道是否有人可以提供资源或建议。
谢谢!
最佳答案
使用集合
$labels = 1..8 | foreach-object { New-Object -TypeName System.Windows.Forms.Label }
$labels | foreach-object { $_.Text = 'text of label' }
关于winforms - 在powershell中编辑生成对象的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51735663/