PropertyGrid. The PropertyGrid control in Windows Forms uses reflection to display all of the properties on any object. You can change the properties.
Property changes are reflected immediately in the user interface. The PropertyGrid looks the same as the property dialogs in Visual Studio.
In this example, we create a Dictionary and then assign it as the SelectedObject. We can then visually browse the Count, all the Keys, and all the Values of the Dictionary instance.
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
// Create an example collection.
var dictionary = new Dictionary<string, string>();
// Assign SelectedObject.
propertyGrid1.SelectedObject = dictionary;
To get started, open your project and add a PropertyGrid. You can change the object whose properties are displayed in the PropertyGrid by assigning to the SelectedObject property.
Note Through reflection, the grid will enumerate all the property members on the object instance and display them.
And In the screenshot, I created a Button and assigned it to the SelectedObject property.
Then I used Visual Studio to change the color of the Button in the grid and also the Text.
SelectedObject. With PropertyGrid, we need to set the SelectedObject property. You can do this in the Visual Studio designer and in an event handler such as Form1_Load.