Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - Help with returning dynamic variable values

$
0
0
Add-Type -AssemblyName System.Windows.Forms
$frm1 = New-Object System.Windows.Forms.form
$frm1.Name = "Hey"

$flw1 = New-Object System.Windows.Forms.FlowLayoutPanel
$flw1.flowdirection = 'TopDown'

$frm1.controls.add($flw1)

$m = "apple","orange","banana"

for($i=0;$i -le $m.Length-1;$i++){

$lb = New-Object System.Windows.Forms.linkLabel
$lb.text = $m[$i]
$m[$i] = $null
$flw1.Controls.Add($lb)
$lb.add_Click({Write-Host $lb.text})
}

$frm1.showdialog()
Could someone please help me with a method to return the value of the label that was clicked? Or a means to identify which linklabel was clicked. Thank you.

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>