Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Powershell GUI + Refresh
    primarykey
    data
    text
    <p>I'm struggling here.</p> <p>Take this sample code:</p> <pre><code>[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Data Entry Form" $objForm.Size = New-Object System.Drawing.Size(500,400) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$output1=$objTextBox.Text}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(100,90) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "Merge" $OKButton.Add_Click({$output=$objTextBox.Text}) $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(300,90) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(160,20) $objLabel.Size = New-Object System.Drawing.Size(280,20) $objLabel.Text = "Please enter the target machine: " $objForm.Controls.Add($objLabel) $output = new-object System.Windows.forms.label $output.location = new-object System.drawing.size(30, 140) $output.size = New-Object System.Drawing.Size(300,300) $objform.controls.add($output) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(115,40) $objTextBox.Size = New-Object System.Drawing.Size(260,20) $objForm.Controls.Add($objTextBox) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $output </code></pre> <p>I can't for the life of me figure out why when I enter text into the box and click the OKButton (Merge) nothing happns. It should be outputted to the $output, or at least, thats what I want to happen.</p> <p>I'm simply trying to get the code to take the input of the text box and output it to the label form called $output.</p> <p>I've got it to work in the sense that when I put input into the text box and press 'Merge', it outputs it to the Powershell_ISE console, but only after the window is closed and in run for a second time (It's not refreshing the $output label when I press 'merge' and only outputs when I close the program)</p> <p>Please help!</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload