How to detect selection in Combo Boxes instead of click.
i have 2 groups in powershell script. 1 has series of combo boxes select options from, , second displays combined result selected combo boxes. trying use $combobox1.add_click detect when update second group, update not happening when select item, updating when click item (prior selection). when review class system.windows.forms.combobox, don't see add_click, guessing add_click alias event click?
- what should using instead of add_click?
- am right add_click same click?
- if events not should looking for, how can list of options similar add_click?
[void] [system.reflection.assembly]::loadwithpartialname("system.drawing") [void] [system.reflection.assembly]::loadwithpartialname("system.windows.forms") $buildings = @("a - nice","b - less nice","c - terrible") $objform = new-object system.windows.forms.form $objform.text = "enter new computer name" $objform.size = new-object system.drawing.size(550,400) $objform.startposition = "centerscreen" #--group1 positions---------------------------------- $gpp1 = 25 #-- defaultmachine name group box---------------------- $group1 = new-object system.windows.forms.groupbox $group1.location = new-object system.drawing.point(30,30) $group1.size = new-object system.drawing.size(500,90) $group1.text = "standard computer name" $group1.enabled = $true #--building label------------------------------------ $g1label1 = new-object system.windows.forms.label $g1label1.location = new-object system.drawing.point(40,$gpp1) $g1label1.size = new-object system.drawing.size(120,15) $g1label1.text = "building" $group1.controls.add($g1label1) #--building------------------------------------------ $g1combo1 = new-object system.windows.forms.combobox $g1combo1.location = new-object system.drawing.point(40,($gpp1+20)) $g1combo1.size = new-object system.drawing.size(120,20) $g1combo1.items.addrange([system.object[]]($buildings)) $g1combo1.selectedindex = 0 $group1.controls.add($g1combo1) #--custom machine name group box----------------------- $group3 = new-object system.windows.forms.groupbox $group3.location = new-object system.drawing.point(30,215) $group3.size = new-object system.drawing.size(500,60) $group3.text = "custom computer name" $group3.enabled = $false #--building label------------------------------------ $g3label1 = new-object system.windows.forms.label $g3label1.location = new-object system.drawing.point(30,$gpp1) $g3label1.size = new-object system.drawing.size(300,15) $g3label1.text = $null $group3.controls.add($g3label1) $clickactions = { $g3label1.text = (($g1combo1.selecteditem).substring(0,1)) } #--this wrong response-------- $g1combo1.add_click($clickactions) $objform.controls.add($group1) $objform.controls.add($group3) [void] $objform.showdialog()
so found .net developer helped me sort out little bit. modified add_click line add_selectedindexchanged, works hoping. guess part don't understand why have put add_ in front of event work in powershell.
Windows Server > Windows PowerShell
Comments
Post a Comment