Add custom properties to propertygrid object in powershell

I want to use the System.Windows.Forms.Property grid to display a number of key value pairs within a Powershell generated GUI.  

[void] [System.Reflection.Assembly]::LoadWithPartialName("System,Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

$pGrid = New-Object System.Windows.Forms.PropertyGrid

...

$pGrid.SelectedObject = MyCommand | Select @{N="Hello"; E={$_.Greeting}}

Open in new window


When loaded this displays the property grid and contains the expected key/value pair of Hello/Greeting. This all works fine but I would like to categorise the key/value pairs (so the above might come under a "General" category). How can I add values to the propertygrid and assign them to a category (creating the category if doesnt already exist)? Also properties usually come with a description so it would be good to set this also - if not hiding the property description panel would be good.

Any experts out there that can help with this will save my bacon!
Blowfelt82Asked:
Who is Participating?
 
Bob LearnedCommented:
I don't have a lot of experience with PowerShell, but you are using the PropertyGrid, which is in the framework, which I do know.  The challenge for me would be to put that knowledge into a context that will work in PowerShell.

Here is an article that explains how to customize the display of an object in the PropertyGrid.  It shows how to use  TypeConverter, PropertyDescriptor, and ICustomTypeDescriptor to customize how the object interacts with the PropertyGrid.

Customized display of collection data in a PropertyGrid
http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.