DataControlBase.SelectedItems Property
Gets or sets a list of data objects that correspond to rows/nodes selected within a View.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v20.1.Core.dll
NuGet Packages: DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
IList | A list of data objects that correspond to rows/nodes selected within a View. |
Remarks
In Multiple Row Selection mode, the GridControl‘s SelectedItems collection is populated with items in the same order rows/nodes are selected.
When the GridControl works in the Server Mode or with Virtual Sources, the SelectedItems collection returns an empty list. Use the DataControlBase.GetSelectedRowHandles and DataControlBase.GetRow / DataControlBase.GetRowAsync methods to obtain row handles and data items.
When you work with the master-detail GridControl, its SelectedItems collection contains items only from the master GridControl. To obtain selected detail records in a DataControlDetailDescriptor:
- Use the detail GridControl‘s DataControlBase.GetSelectedRowHandles method.
- Pass row handles to the GridControl.GetRow / DataControlBase.GetRowAsync method to obtain row data items.
To get selected nodes ordered by visible indexes, use the TreeListControlBase.GetSelectedNodes method. To get row handles of selected items ordered by visible indexes, use the DataControlBase.GetSelectedRowHandles method.
Refer to the Binding to a Collection of Selected Items topic for more information.
Example
The following code sample binds the ListBoxEdit to the SelectedItems collection to show the GridControl‘s selected rows in the ListBox:
<dxg:GridControl x:Name="grid" SelectionMode="Row" ... />
<GroupBox Header="Selected Records">
<dxe:ListBoxEdit ItemsSource="{Binding SelectedItems, ElementName=grid}"
DisplayMember="Name"/>
</GroupBox>
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedItems property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.