我有一个示例代码来创建一个带有文本和小图像的标签的窗体。窗体隐藏()然后显示()总是重新渲染内容
Add-Type -AssemblyName System.Windows.Forms
[Windows.Forms.Application]::EnableVisualStyles()
$label = [Windows.Forms.Label]@{
Image = $image
Height = $image.Height
Text = 'Sample text.'
}
$form = [Windows.Forms.Form]@{
ControlBox = $false
AutoSizeMode = "GrowAndShrink"
AutoSize = $true
FormBorderStyle = "fixedDialog"
AutoScaleMode = "dpi"
StartPosition = "centerScreen"
}
$form.Controls.Add($label)
$form.Show()
显示窗体,但$label
的内容加载较慢,白色背景色。我试图Hide()
然后Show()
的形式,看到它每次重新加载$label
的内容。
请告诉我怎样才能使$label
的内容已经加载,当我Show()
窗体,所以我不会看到每次加载一个白色背景的内容。
'显示()' - >'的ShowDialog()'? –
@AnsgarWiechers'.show()'会显示表单而不会挂起进程,当按下表单的按钮时等待返回值。 – mcuong
据我可以确定一切都按顺序加载,但你的'标签图像'(这在示例中没有定义)是在'标签文本'的前面。我想你实际上是想使用'labelItem'属性将图像放在'label Text'后面。 – iRon