I am making a GUI for some partner center powershell commands. So far I have it losting all our customers names in a combobox but I then need to get the CustomerID for the next stage but all I can return is their name.
I would like to add a property for the ID and then be able to retrieve it when a customer is selected. My code is below but I can't find out how to add $Customer.CustomerID to the item
$ComboBox = New-Object System.Windows.Forms.ComboBox
$ComboBox.Width = 300
$Customers = Get-PartnerCustomer
Foreach ($Customer in $Customers)
{
$ComboBox.Items.Add($Customer.Name);
}
$ComboBox.Location = New-Object System.Drawing.Point(80,10)
$main_form.Controls.Add($ComboBox)
$Label2 = New-Object System.Windows.Forms.Label
$Label2.Text = “Users”
$Label2.Location = New-Object System.Drawing.Point(10,60)
$Label2.AutoSize = $true
$main_form.Controls.Add($Label2)
$Label3 = New-Object System.Windows.Forms.Label
$Label3.Text = “”
$Label3.Location = New-Object System.Drawing.Point(10,90)
$Label3.AutoSize = $true
$main_form.Controls.Add($Label3)
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(400,10)
$Button.Size = New-Object System.Drawing.Size(120,23)
$Button.Text = “Get Users”
$main_form.Controls.Add($Button)
$Button.Add_Click(
{
$Label3.Text = $ComboBox.selectedItem
)
$main_form.ShowDialog()