Author Posts

August 29, 2016 at 9:59 am

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?

August 29, 2016 at 12:21 pm

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.

August 29, 2016 at 12:59 pm

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

  • This reply was modified 2 years, 1 month ago by  Chris Bakker.

August 29, 2016 at 1:56 pm

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.

Untitled20mb image hosting

August 30, 2016 at 7:46 am

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.....

August 30, 2016 at 1:30 pm

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

$cb |gm -membertype event

$tc = {write-host 'do something'}



August 30, 2016 at 1:42 pm

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.

August 31, 2016 at 10:55 am

Found the solution:

$combobox | gm -MemberType Method -Force

Thanks for the input

August 31, 2016 at 1:01 pm

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

August 31, 2016 at 4:04 pm

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.

  • This reply was modified 2 years, 1 month ago by  Chris Bakker.
  • This reply was modified 2 years, 1 month ago by  Chris Bakker.

August 31, 2016 at 4:27 pm

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.