Version

SelectedItems Property

Returns an object that contains collections of selected Records, Fields and Cells
Syntax
'Declaration
 
Public ReadOnly Property SelectedItems As DataPresenterBase.SelectedItemHolder
public DataPresenterBase.SelectedItemHolder SelectedItems {get;}
Remarks

Three types of items can be selected, Records, Cells and Fields. This functionality is controlled by the following properties:

The SelectedItems object exposes 3 collections (DataPresenterBase.SelectedItemHolder.Records, DataPresenterBase.SelectedItemHolder.Cells and DataPresenterBase.SelectedItemHolder.Fields) that can can be used to select/de-select specific items. In addition, selection can be affected by setting the Record's Record.IsSelected, the Cell's Cell.IsSelected and the Field's Field.IsSelected properties.

The following describes how selection behaves in various scenarios:

  • If a user selects records, cells or fields via mouse or keyboard interactions then the SelectedItemsChanging event is raised. If this is not canceled then the appropriate SelectedItems collections are updated and the SelectedItemsChangingSelectedItemsChanged events are raised
  • If any of the IsSelected properties are changed in code or items are added or removed via the SelectedItems collections then the behavior is the same and the SelectedItemsChanging and SelectedItemsChanged events are raised.
  • If the user enters edit mode on a cell then all of the selected collections will be cleared triggering the same SelectedItemsChanging and SelectedItemsChanged events.
  • When records are deleted (either thru changes to the data source or by the user pressing the 'Delete' key) the SelectedItemsChanging event will not be raised even though the SelectedItemsRecords and Cells collections are updated appropriately. However, the SelectedItemsChanged event will be raised. Note if the data source supports deleting records and FieldLayoutSettings.FieldLayoutSettings.AllowDelete property is not set to 'False' then pressing the 'Delete' key will raise the RecordsDeleting event. If this is not canceled then by default the user will be prompted to confirm the deletion of all selected records.
  • If record filtering is active (i.e. FieldSettings.FieldSettings.AllowRecordFiltering is set to 'True' for one or more fields) then selection behaves as follows:
    • If a filter record is being displayed (i.e. FieldLayoutSettings.FieldLayoutSettings.FilterUIType is set to 'FilterRecord' or left to its default value) then entering a filter cell will behave the same as entering any other cell. It will clear the existing selection and raise the events.
    • If filtering is exposed via a drop down inside a field label (i.e. FieldLayoutSettings.FieldLayoutSettings.FilterUIType is set to 'LabelIcons') then changing the filter criteria will leave the existing selections unchanged. Therefore it is possible to, e.g. select 5 records then filter some of them out and then operate on the original 5 selected records. If the data source supports deleting records and FieldLayoutSettings.FieldLayoutSettings.AllowDelete property is not set to 'False' then pressing the 'Delete' key will prompt the user to confirm the deletion of the original 5 selected records. This behavior can be modified by e.g. canceling the RecordsDeleting event and deleting only the 'filtered in' records in code.

Note: Record and Cell selection is mutually exclusive. Selecting one or more Records will automatically clear the Cell selection and vice versa.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also