创建面板后,我需要添加一些文字。要做到这一点,我使用Label
,当我知道需要发布的文本数量时,这很有用。但是,有时不知道标签中需要显示多少文本字符。因此,如果有一种方法在标签中有一个滚动条会很好,所以如果用户想要阅读所有文本,用户可以滚动到它的末尾。
如下所示,我尝试将AutoSize
设置为$True
和固定MaximumSize
。但这并没有带来必要的滚动条..
标签:
$Label = New-Object System.Windows.Forms.Label
$Label.Location = New-Object System.Drawing.Point(8,26)
$Label.MaximumSize = New-Object System.Drawing.Size(528,50)
$Label.AutoSize = $True
$Label.Text = "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd STOP"
#$Label.Text = (Get-Help $MyScript).Description | Out-String
$Label.BackColor = 'Transparent'
$Label.TextAlign = 'TopLeft'
$Panel.Controls.Add($Label)
我找到了类似的thread,但这只涉及自动换行而不是滚动条。
感谢您的帮助。