Skip to content

Selection Property Editing Context

Gary edited this page Aug 27, 2014 · 1 revision

Property editors show properties for selected items, so property editing is context dependent. The key interface for contexts is ISelectionContext, which provides properties and methods to get the selected items and last selected item, change the selection, and so forth. ISelectionContext also provides events for selection changes: SelectionChanging and SelectionChanged. Raising these events allows selections to be tracked and the properties of selected items obtained for property editors.

The SelectionPropertyEditingContext class supports property editing on any ISelectionContext. SelectionPropertyEditingContext implements IPropertyEditingContext, which is for contexts in which properties can be edited by controls, such as PropertyGrid and GridControl, on which the components PropertyEditor and GridPropertyEditor are built.

IPropertyEditingContext defines two properties:

  • Items: Get an enumeration (IEnumerable<object>) of the selected items that have editable properties.
  • PropertyDescriptors: Get an enumeration (IEnumerable<PropertyDescriptor>) of the property descriptors for selected items. These are the property descriptors common to all items in the selection.
These properties are obtained every time the selection changes, that is, when the events in the ISelectionContext interface are raised.

Thus the context can provide a collection of property descriptors whose properties all apply to the current selection. Each property descriptor, in turn, provides all the information needed to edit its property.

Topics in this section

Clone this wiki locally