0

After creating a panel I need to add some text to it. To do this I use a Label, and this works great when I know the quantity of text I need to publish. However, at times it's unknown how much characters of text need to be visible in the label. So it would be nice if there was a way to have a scroll-bar in the label, so users can scroll to the end of it if they want to read all of the text.

As you can see below, I tried to do it by setting the AutoSize to $True and a fixed MaximumSize. But this doesn't bring up the necessary scroll-bar..

Label:

$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)

I found a similar thread, but this only talks about word wrapping and not about scroll-bars.

Thank you for your help.

Community
  • 1
  • 1
DarkLite1
  • 13,637
  • 40
  • 117
  • 214
  • The Label control doesnt have a scroll bar. You will need to create your own custom control if you want to accomplish this with a label. – CathalMF Jan 08 '15 at 12:57
  • 1
    or use a textbox: http://stackoverflow.com/a/2906614/520612 – CB. Jan 08 '15 at 12:59
  • Is there another control that I can use that has this by default? I was looking at the control `TextBox`. But this appears to be used for input, because you can just type in it when used on a form. – DarkLite1 Jan 08 '15 at 13:00
  • @DarkLite1 Have you read the answer in my link? – CB. Jan 08 '15 at 13:03
  • I'm doing it now, your reply came afterwards and wasn't visible when I typed it. I'm sorry.. You are right. Trying the `TextBox` control now. Thank you for your help CB :) – DarkLite1 Jan 08 '15 at 13:05

0 Answers0