how do i get options on $combobox.add_....

I have been playing arount with combobox in powershell.
With the $combobox|get-member you can see a lot of options.
But how do i see what is possible with $combobox.add_? (example $combobox.add_TextChanged)
Is there any way to see what more commands there are possible?

All the properties and methods for all controls are on msdn. If you are using an editor with intellisence you should be able to see them as well.

No, it will show $combobox.TextChanged
But not $combobox.add_TextChanged

Add is when we dynamically add events to a form after it’s loaded. Typically this is done in the form design but sometimes it’s necessary to add/remove events so they are not processed.

Textchanged is the scriptblock that is executed when the event fires.

20mb image hosting

https://msdn.microsoft.com/en-us/library/System.Windows.Forms.ComboBox.aspx

Scroll down to events.

Using powershell ise, add_ commands not in there.
I know what its for, but as intelicense knows what commands there are, you must be able to get the commands throught the powershell command line.
Im Just wondering where and how…

Add-Type -AssemblyName System.Windows.Forms
$form1=New-Object System.Windows.Forms.Form
$cb=New-Object System.Windows.Forms.combobox
$form1.Controls.Add($cb)

$cb |gm -membertype event

$tc = {write-host ‘do something’}

$cb.add_textchanged($tc)

$form1.ShowDialog()

I rarely code forms in notepad anymore, here’s a good article on how the eventhandlers are added in PS.

I’m not a sapien salesman although I should get a commission:D Download the trial and play around with it. It’ll open your mind to how windows forms work.

Found the solution:

$combobox | gm -MemberType Method -Force

Thanks for the input

Incorrect, you said you were looking for the events. There is a big difference.

Yep, bit of confusion there. But it seems that the add_… are listed as methods and can be seen by useing the -force option

PS C:\Users\Chris> $objListBox| gm  -Force -MemberType Method

TypeName: System.Windows.Forms.ComboBox

Name MemberType Definition


add_AutoSizeChanged Method void add_AutoSizeChanged(System.EventHandler value)
add_BackColorChanged Method void add_BackColorChanged(System.EventHandler value)

Sorry for the mixup of terms.

Ah, I get what you’re saying. All the events correspond to the add_ remove_ set_ and since I know that those are my options I don’t need to look up the methods.