[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Testing"
$objForm.Size = New-Object System.Drawing.Size(400,500)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
{$x=$objTextBox.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(20,400)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$x=$objTextBox.Text;$u = $objTextBox2.Text; $objForm.Close()})
$objForm.Controls.Add($OKButton)
#name
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,80)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Please enter your ID:"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,100)
$objTextBox.Size = New-Object System.Drawing.Size(280,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
#[System.Windows.Forms.MessageBox]::Show("$objLabel","TestMSG","OkCancel")
[System.Windows.Forms.MessageBox]::Show("$objLabel.Text","TestMSG","OkCancel")
With $objlabel.text i got this message:
System.Windows.Forms.Label, Text: Please enger your ID:. Text
with only $objlabel, I got this message:
System.Windows.Forms.Label, Text: Please enger your ID:.
All i want is to show/display user's input not the whole line after =