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

Welcome Forums General PowerShell Q&A how do i get options on $combobox.add_....

Viewing 9 reply threads
  • Author
    Posts
    • #52333
      Participant
      Topics: 3
      Replies: 66
      Points: 1
      Rank: Member

      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?

    • #52342
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

      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.

      • #52352
        Participant
        Topics: 3
        Replies: 66
        Points: 1
        Rank: Member

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

    • #52357
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

      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

    • #52359
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member
    • #52435
      Participant
      Topics: 3
      Replies: 66
      Points: 1
      Rank: Member

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

    • #52485
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

      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()

    • #52489
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

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

      http://social.technet.microsoft.com/wiki/contents/articles/25911.how-to-add-a-powershell-gui-event-handler-part-1.aspx

      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.

    • #52671
      Participant
      Topics: 3
      Replies: 66
      Points: 1
      Rank: Member

      Found the solution:

      $combobox | gm -MemberType Method -Force

      Thanks for the input

    • #52680
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

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

      • #52763
        Participant
        Topics: 3
        Replies: 66
        Points: 1
        Rank: Member

        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.

    • #52775
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

      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.

Viewing 9 reply threads
  • The topic ‘how do i get options on $combobox.add_....’ is closed to new replies.