4

I am returning multiple different sizes of strings into a box. I have used a System.Windows.Forms.Label but unfortunately some of the strings are too large for it, and do not display. I have tried replacing it with a System.Windows.Forms.TextBox but it will not let me set the height of it past 1 line, even with multiline set to true, and scrollbars set:

$objTextBox1 = New-Object System.Windows.Forms.TextBox 
$objTextBox1.Multiline = True;
$objTextBox1.Location = New-Object System.Drawing.Size(150,10) 
$objTextBox1.Size = New-Object System.Drawing.Size(300,200)
$objTextBox1.Scrollbars = Scrollbars.Vertical
$objForm1.Controls.Add($objTextBox1) 

Is there anything I'm missing here?

M24Kermit
  • 53
  • 1
  • 1
  • 4

3 Answers3

7
$objTextBox1 = New-Object System.Windows.Forms.TextBox 
$objTextBox1.Multiline = $True;
$objTextBox1.Location = New-Object System.Drawing.Size(150,10) 
$objTextBox1.Size = New-Object System.Drawing.Size(300,200)
$objTextBox1.Scrollbars = "Vertical" 
$objForm1.Controls.Add($objTextBox1)

Options for Scrollbars can be "Vertical", "Horizontal", or "Both".

Bruce Vang
  • 71
  • 1
  • 2
2
$objTextBox1 = New-Object System.Windows.Forms.TextBox 
$objTextBox1.Multiline = $True;
$objTextBox1.Location = New-Object System.Drawing.Size(150,10) 
$objTextBox1.Size = New-Object System.Drawing.Size(300,200)
$objTextBox1.Scrollbars = 3#Scrollbars.Vertical
$objForm1.Controls.Add($objTextBox1) 
Brian Sullivan
  • 345
  • 3
  • 3
  • 1
    It would be good if you could put a little description as well to explain why this solves the problem. – Jonathan Aug 04 '17 at 19:56
0

$objTextBox1.Scrollbars = Scrollbars.Both

[System.Windows.Forms.ScrollBars].GetMembers().Name

Will give you posible memberconversions AND declared members

[System.Windows.Forms.ScrollBars].DeclaredMembers.Name

Will give you posible declared members

ScrollBars will be None, Vertical, Horizontal or Both.

Syscall
  • 19,327
  • 10
  • 37
  • 52
B-Art
  • 69
  • 1
  • 5