Hello,
I want to set values for a group of objects and then reuse those same controls for other groups.
I am not sure what is the right way to approach this or if it is even possible.
I attached an example of what I am envisioning.
Is this on the right track or should it be done a different way?
Thank you.
Reusing groups of 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.
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: Reusing groups of controls
Thank you for the suggestion.
I am looking into that based on these two articles:
https://www.sapien.com/blog/2020/09/08/ ... w-control/
https://www.sapien.com/blog/2015/01/19/ ... -csv-data/
I am looking into that based on these two articles:
https://www.sapien.com/blog/2020/09/08/ ... w-control/
https://www.sapien.com/blog/2015/01/19/ ... -csv-data/
Re: Reusing groups of controls
Simple example:
- Attachments
-
- Demo-DGVComboBox3.psf
- (18.11 KiB) Downloaded 96 times
Re: Reusing groups of controls
Here is more exact example.
- Attachments
-
- Demo-DGVComboBox3.psf
- (15.67 KiB) Downloaded 76 times
Re: Reusing groups of controls
Thank you for the demo. I see how you can set the column type in the Properties window. Do you know how to do this in code?
Another thing I still don't understand is how to populate the rows with data for each column and preserve the column type.
If I use the Update-DataGridView function it appends new columns instead of reusing them by name.
Thank you.
Another thing I still don't understand is how to populate the rows with data for each column and preserve the column type.
If I use the Update-DataGridView function it appends new columns instead of reusing them by name.
Thank you.
Re: Reusing groups of controls
The code shows how to create that empty rows based on the VMs you are trying to configure. It can also be done from a CSV or any other object collection. You can enumerate any collection and create one row per entry in the collection.
Before trying to work with forms, which is an advanced subsystem of Windows and of the Net Framework you will have to learn PowerShell.
Before trying to work with forms, which is an advanced subsystem of Windows and of the Net Framework you will have to learn PowerShell.
Re: Reusing groups of controls
Thank you. I am pretty proficient with PowerShell just not Forms which is where I am trying to learn.
I am working on another demo project and have iteration working for creating the columns and rows as well as assigning $null to the DataSource when changing value groups.
The only part I dont see is how to specify the column type in code. It appears to be using a DataGridViewComboBoxColumn.
I am working on another demo project and have iteration working for creating the columns and rows as well as assigning $null to the DataSource when changing value groups.
The only part I dont see is how to specify the column type in code. It appears to be using a DataGridViewComboBoxColumn.
Re: Reusing groups of controls
You are only working with strings so no column type is needed. The default column in the DGV is a textbox and a string for the ComboBox. No need to change that, just follow my template.
No need to assign $null as reassigning the table will clear the column data when assigning.
You assign the type in the column properties in the column editor of the DGV. Carefully review the columns as I configured them in teh column property editor.
No need to assign $null as reassigning the table will clear the column data when assigning.
You assign the type in the column properties in the column editor of the DGV. Carefully review the columns as I configured them in teh column property editor.