---
title: "System.Windows.Forms.PropertyGrid coolness"
url: "https://osherove.com/blog/2003/3/12/systemwindowsformspropertygrid-coolness.md"
canonical: "https://osherove.com/blog/2003/3/12/systemwindowsformspropertygrid-coolness.html"
published: "2003-03-12T13:38:00"
updated: "2003-03-12T13:38:00"
tags: []
author: "Roy Osherove"
description: "OK. maybe I'm a little slow, but has anyone else tried using the System.Windows.Forms.PropertyGrid control ? It needs to be referenced from the \"Customize toolbox\" menu of the \"tools\" tool window. I'm impressed.…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# System.Windows.Forms.PropertyGrid coolness

By Roy Osherove March 12, 2003

**Historical article** · Originally published March 12, 2003; technical details may be outdated.

OK. maybe I'm a little slow, but has anyone else tried using the System.Windows.Forms.PropertyGrid  control ? It needs to be referenced from the "Customize toolbox" menu of the "tools" tool window.

I'm impressed. Basically, it has the same functionality as the property Grid of the VS.NET IDE. You Assign the **.SelectedObject** property of the grid to any of your objects, and it uses **reflection** to display it's properties. It even lets you manage public collections exposed by the object using a seperate window (just like the VS.NET property grid..) and it's all out of the box functionality. One line of code gets you there and it's pretty customizable as well.  coolness.

One quirk i came across: If you want it to manage your object's public collection of other objects, The object that is added to the collection must expose a default constructor(no params) which allows the default grid designer to create "new" items in the collection and then let you set properties for new items at run time visually.

update:

err. did that make any sense at all?

what i meant in the last paragraph was this: Say you have an object of type "Bank" which has a public collection of "Client" objects named "BankClients". Once you set the "SelectedObject" property of the propertygrid, In the property grid you would see a "BankClients" entry which is described as "collection" and has a little button with 3 dots on it.  if you **click** that button, another dialog opens up and lets you manage the clients collection at run time, letting you add, update and remove client objects from the collection.  The **quirk** above means a Client object must have a default contructor, since in the dialog you get a "Add" button which is supposed to instansiate a new Client object and add it to the collection and then show it visually. then you can set the new objects properties in a property grid that appears in the dialog next to the object's name.

However, since the dialog does not know(or does not care) of any non-default contructors, it will try to always call a default contructor of the object you want to add. if it has none, you get a nice little message box stating that the "Client() contructor has no implementation" or something of the sort....

phew. now i hope **that** made sense.


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
