Hi guys,
I have a question :
I make a gui with 4 combobox and I would like to put in these 4 combobox 4 values of a CSV file.
For example in my csv :
Name;Lastname;age;Country
John;doe;23;USA
I would like to put :
John in combobox1
doe in combobox2
23 in combobox3
USA in combobox4
when I select John in the first combobox manually.
How can i do this plz?
Thanks
Chris
Multi combobox update
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.
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.
Re: Multi combobox update
What you are asking is too vague. You need to describe this better.
If you are looing for how synchronize controls then please tell us what your source is.
Why would you use ComboBoxes to display rows in a CSV, Use a DataGridView.
To sync other controls with a ComboBox use a DataTable. You can load a SCV into a DataTable using "ConvertTo-DataTable".
If you are looing for how synchronize controls then please tell us what your source is.
Why would you use ComboBoxes to display rows in a CSV, Use a DataGridView.
To sync other controls with a ComboBox use a DataTable. You can load a SCV into a DataTable using "ConvertTo-DataTable".
- christouffe
- Posts: 27
- Last visit: Thu Mar 23, 2017 8:29 am
Re: Multi combobox update
I have a powershell form for my computer inventory
When i select a client "LM72,NATINOV,etc..." in the first combobox, I would like the other combobox (Nom machine,Num MTC,etc..) to automatically retrieve information according to the selected client in my csv file.
Is it better decription?
Chris
When i select a client "LM72,NATINOV,etc..." in the first combobox, I would like the other combobox (Nom machine,Num MTC,etc..) to automatically retrieve information according to the selected client in my csv file.
Is it better decription?
Chris
Re: Multi combobox update
What does your CSV file look like?
We wouldn't use ComboBoxes for this. Use textboxes to display associated fields. Bind to a DataTable and you will not need to write any code.
We wouldn't use ComboBoxes for this. Use textboxes to display associated fields. Bind to a DataTable and you will not need to write any code.
- christouffe
- Posts: 27
- Last visit: Thu Mar 23, 2017 8:29 am
Re: Multi combobox update
My csv look like this for each client:
client;Nom machine;num MTC;RAM;DD;Ecran;Taille Ecran
LM72;D-1014253;1014253;2Go:500Go;Samsung;24"
LM72;D-1014254;1014254;8Go:250Go;LG;23"
LM72;D-1014255;1014255;4Go:300Go;HP;22"
LM72;D-1014256;1014256;6Go:800Go;Samsgun;24"
client;Nom machine;num MTC;RAM;DD;Ecran;Taille Ecran
LM72;D-1014253;1014253;2Go:500Go;Samsung;24"
LM72;D-1014254;1014254;8Go:250Go;LG;23"
LM72;D-1014255;1014255;4Go:300Go;HP;22"
LM72;D-1014256;1014256;6Go:800Go;Samsgun;24"
Re: Multi combobox update
Why are you using all ComboBoxes? You can only look at one row at a time. It makes no technical sense is not really possible to do. You also have all duplicate rows. At a minimum you should have one ComboBox and the rest would be textboxes. Load a DataTable and ad it would display one row per client chosen.
- christouffe
- Posts: 27
- Last visit: Thu Mar 23, 2017 8:29 am
Re: Multi combobox update
It is a powershell interface for my on-site technicians that they will use on tablet. I already have a list of hardware on site, they simply need to update this list with this powershell Gui on their tablet
Re: Multi combobox update
I've attached a rough sample that should achieve what you want.
Provide the path to your CSV for each customer in your ComboBox, then load the data into the DataGridView using the same process as I do on lines 20 - 22:
NOTE: The Update-DataGridView cmdlet is added to the psf file when you add the DataGridView object.
EDIT: The TempData.csv contains what OP said was in their client file:
Provide the path to your CSV for each customer in your ComboBox, then load the data into the DataGridView using the same process as I do on lines 20 - 22:
- $PrimalabFile = "D:\Temp\TempData.csv"
- $FileData = Import-Csv -Path $PrimalabFile -Delimiter ';'
- $DataTable = ConvertTo-DataTable -InputObject $FileData
- Update-DataGridView -DataGridView $datagridview1 -Item $DataTable
EDIT: The TempData.csv contains what OP said was in their client file:
client;Nom machine;num MTC;RAM;DD;Ecran;Taille Ecran
LM72;D-1014253;1014253;2Go:500Go;Samsung;24"
LM72;D-1014254;1014254;8Go:250Go;LG;23"
LM72;D-1014255;1014255;4Go:300Go;HP;22"
LM72;D-1014256;1014256;6Go:800Go;Samsgun;24"
- Attachments
-
- DataGridView_Sample.psf
- (35.17 KiB) Downloaded 140 times
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Multi combobox update
For textboxes use the SelectedIndexChanged event to set the other controls. You could also just bind the same table to all ComboBoxes.
Using a grid can only be well synced with a binding adapter.
Using a grid can only be well synced with a binding adapter.
- $cbCustomer_SelectedIndexChanged={
- $txtName.Text = $cbCustomer.SelectedItem.Name
- }