Export (0) Print
Expand All
Expand Minimize

DataGridSelectionMode Enumeration

Specifies constants that define the DataGrid selection modes.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public enum DataGridSelectionMode
<object property="enumMemberName"/>

Member nameDescription
ExtendedThe user can select multiple items while holding down the SHIFT or CTRL keys.
SingleThe user can select only one item at a time.

This enumeration is used by the DataGrid.SelectionMode property. You can programmatically allow single or multiple row selection by setting the DataGrid.SelectionMode property.

The following code example demonstrates how to use the DataGridSelectionMode enumeration. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.


private void cbSelectionMode_Changed(object sender, RoutedEventArgs e)
{
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
    {
        if (cb.IsChecked == true)
            this.dataGrid1.SelectionMode = DataGridSelectionMode.Single;
        else if (cb.IsChecked == false)
            this.dataGrid1.SelectionMode = DataGridSelectionMode.Extended;
    }
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft