How do I add a line feed to a textbox control?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
rkirchhof
Posts: 5
Joined: Sun Mar 03, 2013 12:42 pm

How do I add a line feed to a textbox control?

Post by rkirchhof » Fri Apr 05, 2013 10:26 am

Code: Select all

$buttonGetProxies_Click={
$file=$textbox1.text
$List=Get-Content $file
foreach ($User in $List){
$textbox2.Text = $Textbox2.text + ($User)
$Data = (Get-Mailbox $User -ea silentlycontinue | select-object DistinguishedName -Expandproperty EmailAddresses | select Proxyaddressstring | ft | Out-String)
if ($Data -like $null)
		{
		$textbox2.Text = $Textbox2.text + " Has no Proxy addresses." 
		}
else
	{
	$textbox2.Text = $Textbox2.text + $Data
	}
}
}
I need to add a line feed on this line $textbox2.Text = $Textbox2.text + " Has no Proxy addresses." I've tried 'r'n /r/n &chr(13) and everything else I can think of, but none of them work.

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: How do I add a line feed to a textbox control?

Post by davidc » Fri Apr 05, 2013 10:36 am

Do you have the TextBox configured to use Multiline text?

See the Spotlight on the Text control for more info:

http://www.sapien.com/blog/2011/06/13/p ... x-control/

David
David
SAPIEN Technologies, Inc.

User avatar
rkirchhof
Posts: 5
Joined: Sun Mar 03, 2013 12:42 pm

Re: How do I add a line feed to a textbox control?

Post by rkirchhof » Fri Apr 05, 2013 10:42 am

Yes I did enable multiline. I just tried this too.
$textbox2.AppendText(" Has no Proxy addresses.'r'n")
Taken straight from the link above and this is the output.

BEETRoot@cru.org Has no Proxy addresses.'r'npledgesupport@cru.org

this is what I wish to see:

BEETRoot@cru.org Has no Proxy addresses.
pledgesupport@cru.org

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: How do I add a line feed to a textbox control?

Post by davidc » Fri Apr 05, 2013 11:15 am

I see the problem. You are using single quote instead of the backtick.

Try this:
PowerShell Code
Double-click the code block to select all.
$textbox2.AppendText(" Has no Proxy addresses.`r`n")
David
David
SAPIEN Technologies, Inc.

User avatar
rkirchhof
Posts: 5
Joined: Sun Mar 03, 2013 12:42 pm

Re: How do I add a line feed to a textbox control?

Post by rkirchhof » Fri Apr 05, 2013 11:22 am

ARRGGGG! I feel Soooo Stupid! Thanks' a bunch! Of course that did it.

Locked