If the add a ListView control to a form a couple of helper items are added.
How would I use the "Add-ListViewItem" to populate the control from say using the following: (get-volume | select -property DriveLetter, FileSystemLabel). Playing around with the helper function I cannot get it to add anything. I am trying to add it via the form load event.
Pete
Using the ListView control Add-ListViewItem helper
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
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 LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- PGomersall
- Posts: 138
- Last visit: Thu Apr 11, 2024 7:51 am
Re: Using the ListView control Add-ListViewItem helper
Depends on what you wish to display and how.
If you want to display the drive letter and label you could try the following:
http://www.sapien.com/blog/2012/04/04/s ... ol-part-1/
You can use a DataGridView as an alternative.
If you have further questions about using the GUI controls, we have a forum dedicated to the subject:
PowerShell GUIs
David
If you want to display the drive letter and label you could try the following:
PowerShell Code
Double-click the code block to select all.$volumes = get-volume foreach($drive in $volumes) { Add-ListViewItem -ListView $listview1 -Items $drive.DriveLetter -SubItems $drive.FileSystemLabel }The ListView can be a complicated control. I recommend reading the Spotlight on the ListView control article:
http://www.sapien.com/blog/2012/04/04/s ... ol-part-1/
You can use a DataGridView as an alternative.
If you have further questions about using the GUI controls, we have a forum dedicated to the subject:
PowerShell GUIs
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- PGomersall
- Posts: 138
- Last visit: Thu Apr 11, 2024 7:51 am
Re: Using the ListView control Add-ListViewItem helper
David,
Tried the code you suggest, but it doesn't return any data to the ListView control.
Pete
Tried the code you suggest, but it doesn't return any data to the ListView control.
Pete
Re: Using the ListView control Add-ListViewItem helper
I didn't validate any of the fields or names. You will have to make sure you aren't using the wrong variable name.
I recommend running it through the debugger or just output the values.
David
I recommend running it through the debugger or just output the values.
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.