Powershell GUI - fill second line of textbox from array

Hi forum,

does anyone know, how to fill the second (or third, fourth…) line of a (multiline) textbox from an array?
I always overwrite the first line, when I do a “$Textbox1.text = $MyArray[$counter]”

Thanks for any suggestion
newbi

The text box isn’t indexable so you can’t access indivdual lines. You’ll have to append to the current text. If you’re actually incrementing, then:

$Textbox1.Text = $Textbox1.Text + "`r`n" + $MyArray[$Counter]

If you just want to output the array, then use -join:

$Textbox1.Text = $MyArray -join "`r`n"

Also, a gentle reminder to always format your code properly when making forum posts:

How to format code on PowerShell.org