Search code examples
c#.netwinformspropertygrid

Using Properties Window in runtime to customize windows form controls


Is there a way to use visual studio design-time Properties Window at runtime to customize a specific Control such as DataGridView?

Some thing like image below needed to enable user to customize controls on a Form by changing properties of them.

enter image description here


Solution

  • The PropertyGrid is a standard control. You can add one to your Form or create it at run-time.
    In the ToolBox, it's usually found in the All Windows Forms cathegory, or using the search tool.
    It can be fully customized and supports transparent colors.

    You can use the SelectedObject property to associate it to an existing control and it will populate automatically (this property can also be set at design-time).

    The PropertyGrid can then be used to change the associated control's properties at run-time.

    propertyGrid1.SelectedObject = this.dataGridView1;
    


    Property Grid Control