I have just discovered the propertygrid control.
I can assign an object to it using the selectedobject property.
What I cant work is how to assign attributes to elements within the object such as descriptionattribute and categoryattribute.
I found some reference to system.componentmodel but cannot find examples of how to use this in powershell to assign element attributes in the propertygrid.
Thanks
David
propertygrid element attributes
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: propertygrid element attributes
Here is about the simplest example I can come up with on short notice.
Run it at a prompt and see that it can directly set a string object.
Run it at a prompt and see that it can directly set a string object.
- Add-Type -AssemblyName System.Windows.Forms
- function ObjectViewer {
- Param($obj)
- $form = new-object "System.Windows.Forms.Form"
- $form.Size = new-object System.Drawing.Size @(600, 600)
- $PG = new-object "System.Windows.Forms.PropertyGrid"
- $PG.Dock = [System.Windows.Forms.DockStyle]::Fill
- $form.text = "$args"
- $PG.selectedobject = $obj
- $form.Controls.Add($PG)
- $form.topmost = $true
- $form.showdialog()
- }
- $o = [System.Windows.Forms.TextBox]::New()
- # when visible change the "Text" property
- ObjectViewer $o
- # Now display the Text of the control
- $o.Text