problem with radio buttons and comboboxes

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
mhenders
Posts: 4
Joined: Tue Oct 03, 2017 7:44 am

problem with radio buttons and comboboxes

Post by mhenders » Tue Mar 13, 2018 11:24 am

I am trying to use three radio buttons on a form. My problem resides with the use of the "waitcursor". It takes a little time for my AD to be queried and the names placed in a combobox and whil waiting, I want to change the cursor to the waitcursor. If I select the button for 'xxxxxx', the cursor changes, the comboxbox is populated, and the cursor changes back to normal. If I then select the button for yyyyyy or zzzzzz, the cursor never changes even though the combobox is populated with the correct names. Can someone please bless my ignorance and tell me what I am doing wrong or why this behavior is happening.

Thanks!!!!!


$radiobuttonxxxxxx_CheckedChanged={
#TODO: Place custom script here
$MainFormDRT.UseWaitCursor = $true
$comboboxUserName.Items.Clear()
$adusers = Get-ADUser -SearchBase 'OU=xxxxxx,DC=eatmopossum,DC=org' -Filter '*' | Select -Exp Name
Update-ComboBox -ComboBox $comboboxUserName -Items $adusers
$comboboxUserName.SelectedIndex = 0
$MainFormDRT.UseWaitCursor = $false
}

$radiobuttonyyyyyy_CheckedChanged={
#TODO: Place custom script here
$MainFormDRT.UseWaitCursor = $true
$comboboxUserName.Items.Clear()
$adusers = Get-ADUser -SearchBase 'OU=yyyyyy,DC=eatmopossum,DC=org' -Filter '*' | Select -Exp Name
Update-ComboBox -ComboBox $comboboxUserName -Items $adusers
$comboboxUserName.SelectedIndex = 0
$MainFormDRT.UseWaitCursor = $false
}

$radiobuttonzzzzzz_CheckedChanged={
#TODO: Place custom script here
$MainFormDRT.UseWaitCursor = $true
$comboboxUserName.Items.Clear()
$adusers = Get-ADUser -SearchBase 'OU=zzzzzz,DC=eatmopossum,DC=org' -Filter '*' | Select -Exp Name
Update-ComboBox -ComboBox $comboboxUserName -Items $adusers
$comboboxUserName.SelectedIndex = 0
$MainFormDRT.UseWaitCursor = $false
}

User avatar
jvierra
Posts: 12270
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: problem with radio buttons and comboboxes

Post by jvierra » Tue Mar 13, 2018 11:52 am

Like this:

Code: Select all

$radiobutton1_CheckedChanged={
	$form1.Cursor = 'WaitCursor'
    # action code
	$form1.Cursor = 'Default'
}

User avatar
mhenders
Posts: 4
Joined: Tue Oct 03, 2017 7:44 am

Re: problem with radio buttons and comboboxes

Post by mhenders » Tue Mar 13, 2018 12:13 pm

thanks for the assist, it is working like I wanted it to.

Many, many THANKS!!!

Locked