Search code examples
powershellpowershell-2.0powershell-3.0

Powershell Studio 2018 - How to retrieve textbox values properly?


I am having an issue with retrieving values from objects in Powershell Studio 2018 but my main issue is with the TextBox object. I have a wizard form that contains a textbox on step one. I would like to retrieve the output of that textbox in step two of the wizard. However, when I try to retrieve it by using:

$textboxname.Text 

I receive the following output instead of the entered value:

System.Windows.Forms.Text. Text:

I have checked all of the documentation but cannot figure out what I am doing wrong. I have also tried to use the .ToString property without any luck. Any help would be greatly appreciated!


Solution

  • It is not clear in your question but are you saving content of the textbox to a variable?

    As an example this snippet works perfectly

    $button1_Click={
    #TODO: Place custom script here
    
    [System.Windows.Forms.Clipboard]::SetText($textbox1.text)
    

    }

    The above is copying to clipboard but similarly you can do that with a variable.

    On the other hand if you're trying to read the value of textbox1 from a child form, assuming a multi form project, that won't work.

    Let me know if this helps or if you can give us some more details I can try to reproduce the issue on my side but having a snippet of the code is not working for your would be beneficial.