GUI WPF Search Function within

Welcome Forums General PowerShell Q&A GUI WPF Search Function within

Viewing 6 reply threads
  • Author
    Posts
    • #197150
      Participant
      Topics: 5
      Replies: 6
      Points: 72
      Rank: Member

      hello there powershell brothers and sisters,

      I’m playing a bit with WMF and trying to figure out how to create a search field or search function in a list.

      For example, I have a list box containing all expired accounts, instead of scrolling I want to enter the name. But I have no idea how to define such an object.

      Does anyone know a good book that covers everything around Powershell GUI.

       

      Kind regards,

      • This topic was modified 8 months, 2 weeks ago by mtasova.
    • #197165
      Participant
      Topics: 25
      Replies: 184
      Points: 657
      Helping Hand
      Rank: Major Contributor

      Best i can point you to would be Learn Powershell toolmaking in a month of lunches.

      https://www.manning.com/books/learn-powershell-toolmaking-in-a-month-of-lunches

       

      its not going to answer all of your questions, but the big thing to learn, is all of the elements in your gui, are just objects, you interact with them in the same way you deal with any other object in powershell.

    • #197171
      Participant
      Topics: 5
      Replies: 6
      Points: 72
      Rank: Member

      Thanks for the tip David.

      I will look whats been covered.

    • #197240
      Participant
      Topics: 5
      Replies: 6
      Points: 72
      Rank: Member

      :((

      function keuze{

      [string]$results = $ExpiredAccountCombo.Text.ToString()

      }

      The selected within the combox value gets in $ExpiredAccountCombo.Text.ToString()  but [string]$results =ExpiredAccountCombo.Text.ToString() is not putting the value in the variable….

      What am I doing wrong ?

       

       

       

       

       

      ——code —

      Add-Type -AssemblyName System.Windows.Forms
      [System.Windows.Forms.Application]::EnableVisualStyles()

      $Form = New-Object system.Windows.Forms.Form
      $Form.ClientSize = ‘890,722’
      $Form.text = “Form”
      $Form.TopMost = $false

      $ExpiredAccounts = New-Object system.Windows.Forms.Label
      $ExpiredAccounts.text = “Expired Accounts:”
      $ExpiredAccounts.BackColor = “#b8e986”
      $ExpiredAccounts.AutoSize = $true
      $ExpiredAccounts.width = 40
      $ExpiredAccounts.height = 10
      $ExpiredAccounts.location = New-Object System.Drawing.Point(14,8)
      $ExpiredAccounts.Font = ‘Microsoft Sans Serif,10,style=Bold,Underline’

      $ExpiredAccountCombo = New-Object system.Windows.Forms.ComboBox
      $ExpiredAccountCombo.text = “Expired Accounts”
      $ExpiredAccountCombo.width = 255
      $ExpiredAccountCombo.height = 20
      $ExpiredAccountCombo.location = New-Object System.Drawing.Point(15,52)
      $ExpiredAccountCombo.Font = ‘Microsoft Sans Serif,10’

      $Form.controls.AddRange(@($ExpiredAccounts,$ExpiredAccountCombo))

      $ExpiredAccountCombo.Add_Click({ Keuze })

      foreach ($item in $users )
      {
      $ExpiredAccountCombo.Items.Add($item.displayname)
      #$Expiredusers.Items.Add($ActiveSyncStatus.$($item.name))
      #$ExpiredAccounts
      }

      function keuze{

      [string]$results = $ExpiredAccountCombo.Text.ToString()

      }

      [void] $Form.ShowDialog()

    • #197396
      Participant
      Topics: 1
      Replies: 2
      Points: 27
      Rank: Member

      Have you tried putting your function at the top of the code? It should be one of the first things that initializes when the code runs. I’ve been working with WPF quite a bit recently and have been tripped up quite a bit with making sure I was calling my variables and functions in the right order or else they didn’t work as expected.

    • #197405
      Participant
      Topics: 13
      Replies: 1753
      Points: 3,136
      Helping Hand
      Rank: Community Hero

      There are many examples of creating forms with Powershell. There are tools and entire websites dedicated to it. When I want to build something like this, I find examples close to what I’m trying to accomplish to use as a framework and make changes to fit the requirements. It also looks like you are trying to get information in a GUI and then exit the GUI to do something with that information. Typically, you would execute processes on selections with button clicks (or other events) rather than trying to use the GUI to gather information and exit to process it.

      • This reply was modified 8 months, 1 week ago by Rob Simmers.
    • #198134
      Participant
      Topics: 4
      Replies: 5
      Points: 38
      Rank: Member

      Try this

       

Viewing 6 reply threads
  • The topic ‘GUI WPF Search Function within’ is closed to new replies.