Export (0) Print
Expand All

DataGrid.CanUserReorderColumns Property

Gets or sets a value that indicates whether the user can change the column display order by dragging column headers with the mouse.

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

public bool CanUserReorderColumns { get; set; }
<sdk:DataGrid CanUserReorderColumns="bool"/>

Property Value

Type: System.Boolean
true if the user can reorder columns; otherwise, false.

Dependency property identifier field: CanUserReorderColumnsProperty

You can set this behavior for individual columns by setting the DataGridColumn.CanUserReorder property. If the DataGridColumn.CanUserReorder property and the DataGrid.CanUserReorderColumns property are both set, a value of false will take precedence over a value of true.

Columns can be frozen by setting the FrozenColumnCount property greater than 0. Frozen columns are always the leftmost columns in display order. You cannot drag frozen columns into the group of unfrozen columns or drag unfrozen columns into the group of frozen columns.

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


private void cbColReorder_Changed(object sender, RoutedEventArgs e)
{
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
        this.dataGrid1.CanUserReorderColumns = (bool)cb.IsChecked;
}


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