trying to update textbox text based on another textbox but it isn't working
ok have following script.
$mainform = new-object system.windows.forms.form
$mainform.text = "assign $lu $newpcname"
$mainform.size = new-object system.drawing.size(600,250)
$mainform.startposition = "centerscreen"
$mainform.autoscroll = $true
$mainform.font = new-object system.drawing.font("californian fb", 14,[system.drawing.fontstyle]::bold)
$mainform.formborderstyle = "fixeddialog"
$mainform.maximizebox = $false
$npnlb = new-object system.windows.forms.label
$npnlb.size = new-object system.drawing.size(130,25)
$npnlb.location = new-object system.drawing.point(5,16)
$npnlb.text = "pc name: "
$npntb = new-object system.windows.forms.textbox
$npntb.location = new-object system.drawing.point(140,14)
$npntb.size = new-object system.drawing.size(150,35)
$npntb.text = $newpcname
$npntb.add_mouseenter({$this.backcolor = [system.drawing.color]::fromargb(6,139,138)})
$npntb.add_mouseleave({$this.backcolor = [system.drawing.color]::white})
$npntb.add_textchanged({$newpcname = $npntb.text; $mainform.refresh()})
$npntb.tabindex = 1
so have read telling me when change text in $npntb.text then $npntb.add_textchanged should fire , main form title should change reflect updated variable. not happening. there no changes form title. simplest of 2 of these trying work. figure if folks can me part other 1 should easy. have posted relevant portion of long , complicated script here.
help about_scope
also:
this line not assign variable "text" assigns current value of variable. if change variable not change forms "text" property. basic programming 101 , true in languages.
example:
ps c:\scripts> $x=4 ps c:\scripts> $y=$x ps c:\scripts> $y 4 ps c:\scripts> $x=99 ps c:\scripts> $y 4
help about_variables
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment