[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Collapse]Property Grid
    Office View
    How to: Filter an object's properties using the CustomPropertyDescriptors event
    How to: Edit properties of multiple objects in a single PropertyGridControl
    How to: Sort properties using the CustomPropertyDescriptors event
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Property Grid

The PropertyGridControl reveals object properties and allows you to modify them while an application is running.

Expanded Select an Inspected Object

To inspect and modify object settings, assign that object to the PropertyGridControl.SelectedObject property.

At runtime, you can specify the SelectedObject in code to browse and modify any business object's settings. In the figure below, the LookUpEdit is bound to a list that contains records. Selecting a record fires the RepositoryItem.EditValueChanged event, which allows you to browse the selected Product.

Expanded Inspect Multiple Objects

You can use the PropertyGridControl.SelectedObject property to choose a single object whose properties you want to inspect, and the PropertyGridControl.SelectedObjects collection to access an array of inspected objects. In this case, the Property Grid control displays only those properties that apply to all objects in this array.

Expanded Filter Retrieved Rows

If you need to hide specific Property Grid rows, handle the PropertyGridControl.CustomPropertyDescriptors event. The following code illustrates how to hide a row generated for the "Price" data source field.

See also: How to: Filter an object's properties using the CustomPropertyDescriptors event | How to: Sort properties using the CustomPropertyDescriptors event

Expanded Customize Auto-Generated Rows

In the example above, all Property Grid rows are generated automatically based on the selected object type and properties. You can also create and modify rows manually. Rows are stored in the VGridControlBase.Rows collection and can be retrieved either from this collection by row indexes, or by calling the VGridControlBase.GetRowByFieldName method in code. The code below applies currency formatting to auto-generated "Price" rows.

Expanded Manually Add Rows

Invoke the Property Grid smart tag and click "Run Designer". Switch to the Designer's "Rows" tab and click the "Add (EditorRow)" button to manually add a row.

These regular data rows are EditorRow class objects.

Important

A control does not automatically create additional rows if a Property Grid contains at least one manually created data row.

Expanded Nested Rows

In the Designer "Row" tab, drag one row to another to create a row hierarchy.

Note

Related API * BaseRow.Expanded - gets or sets whether this parent row is expanded.

To drag a child row from its parent back to the top level, drag-and-drop it while holding down the "Ctrl" key.

Expanded Populate Manually Created Rows

Rows you add manually display nothing at runtime. You can populate such rows in two different ways.

  • When you need rows with values not associated with SelectedObject properties, create unbound rows that derive from the System.ComponentModel.PropertyDescriptor class and handle the PropertyGridControl.CustomPropertyDescriptors event. See this example to learn more.
  • If manually added rows should display SelectedObject property values, assign these property names to row RowProperties.FieldName properties.

Expanded Multi-Editor Rows

Multi-editor rows (MultiEditorRow objects) combine multiple simple data rows into one row.

At design time, you can create multi-editor rows in the Property Grid Designer.

To populate a multi-editor row, modify the MultiEditorRow.PropertiesCollection. Each collection item represents a regular EditorRow with standard row settings - Caption, FieldName, etc.

The following sample illustrates how to add a multi-editor row in code.

Expanded Category Rows

Category rows allow you to organize multiple data rows into a group and provide a caption for it.

To add categories at design time, go to the Designer "Rows" tab and use the "Add" button's drop-down menu. Then, drag-and-drop regular data rows onto this category to populate it.

Note

Related API * BaseRow.Expanded - allows you to manually expand and collapse categories.

In code, the CategoryRow class instances represent categories. The following sample illustrates how to add a category.

Expanded Fixed Rows

If a Property Grid control is too small to display all rows at once, it shows a vertical scrollbar. Rows can anchor to the control's top or bottom edge, and remain visible as users scroll through records. To fix a row, specify its BaseRow.Fixed property. In the following animation, the "Appearance" category is anchored to the control's top.

Important

The BaseRow.Fixed property is in effect only for top-tier rows. If a row is another row's child or belongs to a category, it cannot be anchored. Alternatively, specify the parent row's Fixed property.

You can use the VGridControlBase.FixedTopRows and VGridControlBase.FixedBottomRows collections to retrieve fixed rows.

Expanded Row Editors

Position and Alignment (Office View Only)

A property row consists of a caption and an editor. Editors are positioned after captions for all types except for booleans. You can customize the editor position using the row's EditorPosition property. If an editor is postioned after a caption, you can align it far from or near to the caption, or at the center using the row's EditorAlignment property.

Representation of a Property's Value (Classic View Only)

You can provide a custom editor for a property using the Editor attribute.

See UITypeEditor on MSDN for more information on how to implement a custom edtior.

The UITypeEditor type exposes the virtual PaintValue and GetPaintValueSupported methods that you can override to support the display of a value's representation.

To enable the property grid to use the provided representation, set the PGridOptionsView.AllowPaintValue property to true.

Expanded Find Panel

A Property Grid can display the Find Panel to help end-users locate the required settings by their names. To invoke this tool, press "Ctrl+F" at runtime.

Note

Related API * VGridControlBase.FindPanelVisible - specifies whether the find panel is initially shown.

  • VGridControlBase.OptionsFind - provides advanced Find Panel options that allow you to hide specific buttons, change the auto-search delay, specify whether the results should be highlighted, etc.

Expanded Context Menu

The property grid can display a context menu for properties. The menu contains the predefined Reset command that sets the property to its default value. You can also provide custom commands by handling dedicated events. To invoke the menu, users can right-click a property or click a brick button (Office view only).

Right-click

With a right-click, the menu is enabled by default. Use the PropertyGridControl.OptionsMenu.EnableContextMenu property to disable the menu (see VGridOptionsMenu.EnableContextMenu). To populate the menu with custom commands, handle the VGridControlBase.PopupMenuShowing event.

Note

Items added using the PopupMenuShowing event are also shown when the menu is invoked with a click on a brick button against a property (see below).

Click a brick button

Brick buttons are only available in the Office view (see PropertyGridControl.ActiveViewType). To show brick buttons, set the PropertyGridControl.OptionsView.ShowRowBrick property to True (see PGridOptionsView.ShowRowBrick). To populate the menu, handle the PropertyGridControl.RowBrickMenuShowing event.

Note

Items added using the RowBrickMenuShowing event are not shown when the menu is invoked with a right-click on a property.

Brick buttons can be customized by handling the PropertyGridControl.CustomDrawRowBrick event.

Expanded See Also

Is this topic helpful?​​​​​​​