Hi,
I'm trying to assing a multiline value to a textbox but it put everything on the same line.
The multiline property of the textbox is at True.
When I do a write-host of my variable it show on differents lines.
$example = "Hi
Car
Today"
$I_INFO_SUPP.text = $example
The result is "HiCarToday"
Thanks
assing a multiline value to a textbox
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.
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.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: assing a multiline value to a textbox
Simple fix!
You need to use the Here-String text format the following way:
$example = @"Hi
Car
Today
"@
For more information look at the following link: https://technet.microsoft.com/en-us/lib ... 92792.aspx
Otherwise the previous format will be understood as a one line string no matter how you'll break it within the double (or single) quotes.
You need to use the Here-String text format the following way:
$example = @"Hi
Car
Today
"@
For more information look at the following link: https://technet.microsoft.com/en-us/lib ... 92792.aspx
Otherwise the previous format will be understood as a one line string no matter how you'll break it within the double (or single) quotes.
Re: assing a multiline value to a textbox
I do not see that at all. Using sunlister's example and assigning to a multiline textbox produces individual lines.
See attached example.
See attached example.
- Attachments
-
- Test-TextBoxFormats.psf
- (22.87 KiB) Downloaded 124 times
Re: assing a multiline value to a textbox
I also can not reproduce the error that Sunlister is getting.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: assing a multiline value to a textbox
The only way I can replicate the issue would be by leaving the text box multiline property as "False". Otherwise setting it to "True" and resizing the textbox then it will work with either single, double quotes, and here-string format.
Re: assing a multiline value to a textbox
I suspect t that this could indicate that the OP is setting the multiline property at the wrong time although, if the box is expanded then it must be set to $true.
There is also a possible problem using Net 1.0 or 2.0. All updates to Net 2.0 seem to have fixed some of the odd behaviors of the initial versions. I have no way of testing so this is just from memory.
There is also a possible problem using Net 1.0 or 2.0. All updates to Net 2.0 seem to have fixed some of the odd behaviors of the initial versions. I have no way of testing so this is just from memory.