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.
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
lontru
Posts: 103
Last visit: Sun Apr 14, 2024 11:13 pm
Post
by lontru » Sat Dec 08, 2018 3:32 am
Hi am tryin to create a function to update combobox but stuck in how to define the combobox
Update-ComboBox $combobox (Get-ChildItem "$Path" -Directory) "Name
How to pass the param $combobox to Update-ComboBox Comboxbox
and keep the $
RefreshCombobox -Combobox combobox_Vendor -Path "C:\SD"
pass the value as "combobox_Vendor" and i need it as $combobox_Vendor
is this possible?
Code below
Code: Select all
$CreateAppStructure_Load={
#TODO: Initialize Form Controls here
RefreshCombobox -Combobox combobox_Vendor -Path "C:\SD"
}
#region Control Helper Functions
#endregion
function RefreshCombobox ($combobox,$Path)
{
Update-ComboBox $combobox_Vendor (Get-ChildItem "$Path" -Directory) "Name"
}
code sample for creating the folder for the form.
Code: Select all
New-Item c:\SD -ItemType Directory
1..10 | foreach {
$i++
New-Item c:\SD\Folder$($i) -ItemType Directory
}
Attachments
CreateAppStructure.psf
(156.84 KiB) Downloaded 150 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times
Post
by jvierra » Sat Dec 08, 2018 10:15 am
Just use the correct variables.
Code: Select all
$CreateAppStructure_Load={
#TODO: Initialize Form Controls here
RefreshCombobox -Combobox $combobox_Vendor -Path C:\SD
}
function RefreshCombobox ($Combobox, $Path) {
Update-ComboBox $Combobox (Get-ChildItem $Path -Directory) Name
}
[code]
lontru
Posts: 103
Last visit: Sun Apr 14, 2024 11:13 pm
Post
by lontru » Sat Dec 08, 2018 1:24 pm
wierd i did the same thing but got error must been an typo
lontru
Posts: 103
Last visit: Sun Apr 14, 2024 11:13 pm
Post
by lontru » Tue Dec 11, 2018 2:25 pm
I did some more work on the application but stuck on this wierd behavior.
The combobox vendor works fine when typing but the combobox product type ind wierd?
I recorded it in the gif. I type in test but get it backwards? as tset? have compare the to combobox and cant spot the different?
is the psf file damage/corrupt?
attached the psf below.
Attachments
CreateAppStructure.psf
(92.78 KiB) Downloaded 185 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times
Post
by jvierra » Tue Dec 11, 2018 3:09 pm
Remove the extra attachment to the event under "properties changed"
lontru
Posts: 103
Last visit: Sun Apr 14, 2024 11:13 pm
Post
by lontru » Wed Dec 12, 2018 12:32 am
Is it this property?
I have the same on the vendor combo box and i can type in fine there?
lontru
Posts: 103
Last visit: Sun Apr 14, 2024 11:13 pm
Post
by lontru » Wed Dec 12, 2018 12:39 am
hmm after i removed the "$combobox_Products_TextChanged" section i can type in normaly?
But i want the textchanged event on the combobox so i can check if the folder exist?
think i found the bug I clear the combobox under textchange
$combobox_Products.Items.Clear()
changed it to
$combobox_SoftwareVersion.Items.Clear()
and the gui function as i wanted
Code: Select all
if (Test-Path -Path "$SDpath\$($combobox_Vendors.Text)\$($combobox_Products.Text)" -PathType Container)
{
$versions = Get-ChildItem -Path "$SDpath\$($combobox_Vendors.Text)\$($combobox_Products.Text)" | Select-Object -ExpandProperty Name
foreach ($version in $versions)
{
if ($version -match '^[a-zA-Z]')
{
Update-ComboBox $combobox_Environments "$version" -Append
$combobox_Environments.Enabled = $true
}
else
{
Update-ComboBox $combobox_SoftwareVersion "$version" -Append
$combobox_SoftwareVersion.Enabled = $true
}
}
}
else
{
$combobox_Products.Items.Clear()
$statusbar1.Text = "New vendor: $($combobox_Vendors.Text) - Fill out vendor name"
}
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked