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.
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
I searched for a solution for my issue with AppendText but didn't find anything.
trying to append the input from multiple text boxes into a "summary" text box but it is adding the below text marked in red for each input
i'm missing something obvious to avoid this and prevent that text from appearing, thanks for any help!
$buttonProvision_Click={
#TODO: Place custom script here
if ($radiobuttonInvited.Checked -eq $true)
{
$usertype = "invited"
}
$results.ForeColor = 'Green'
$results.Text = "User type is '$usertype'`r`n"
$results.AppendText("First Name is '$FirstName'`r`n")
$results.AppendText("Last Name is '$LastName'")
}
contents of the "summary" text box:
User type is 'invited'
First Name is 'System.Windows.Forms.TextBox, Text: John'
Last Name is 'System.Windows.Forms.TextBox, Text: Smith'
So $lastname is the same as $LastName
$lastname = $LastName.text
So this statement assigns the text in the $LastName object to the object itself.
That'll screw things up royally.
I would recommend to name things a little differently.
I name controls with a 'Ctl' suffix. So
$LastName would become $LastNameCtl
The variable you use to assign the content to is a string. So you could name it
$strLastName or $LastNameStr to make sure when you look at the code you know what is what.
I personally use a type prefix but a suffix for generic things like 'Control', but that is a personal thing for you to develop.
So $lastname is the same as $LastName
$lastname = $LastName.text
So this statement assigns the text in the $LastName object to the object itself.
That'll screw things up royally.
I would recommend to name things a little differently.
I name controls with a 'Ctl' suffix. So
$LastName would become $LastNameCtl
The variable you use to assign the content to is a string. So you could name it
$strLastName or $LastNameStr to make sure when you look at the code you know what is what.
I personally use a type prefix but a suffix for generic things like 'Control', but that is a personal thing for you to develop.
thanks, Alexander! pointed me in the correct direction and output is as expected now
made no alterations under the individual controls
$buttonProvision_Click = { $FirstNameSTR = $FirstNameCTL.text
$LastNameSTR = $LastNameCTL.text
#TODO: Place custom script here
if ($radiobuttonInvited.Checked -eq $true)
{
$usertype = "invited"
}
$results.ForeColor = 'Green'
$results.Text = "User type is '$usertype'`r`n" $results.AppendText("First Name is '$FirstNameSTR'`r`n")
$results.AppendText("Last Name is '$LastNameSTR'")
}
contents of the "summary" text box now:
User type is 'invited'
First Name is 'John'
Last Name is 'Smith'
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.