DataGrid for WPF and Silverlight Overview / DataGrid Features / Sorting / Disabling Column Sorting
Disabling Column Sorting

By default end users can sort columns in the grid at run time. For more information, see Sorting Columns. If you choose, however, you can disable the column sorting feature by setting the CanUserSort property to False.

At Design Time

To disable column sorting, complete the following steps:

  1. Click the C1DataGrid control once to select it.
  2. Navigate to the Properties window and locate the CanUserSort property.
  3. Clear the check box next to the CanUserSort property.

In XAML

For example to disable column sorting, add CanUserSort="False" to the <c1:C1DataGrid> tag so that it appears similar to the following:

<c1:C1DataGrid Name="c1datagrid1" Height="180" Width="250" CanUserSort="False" />

In Code

For example, to disable column sorting, add the following code to your project:

Visual Basic
Copy Code
Me.C1DataGrid1.CanUserSort = False

 

C#
Copy Code
this.c1DataGrid1.CanUserSort = false;

 

What You've Accomplished

Run the application and observe that you can no longer sort columns at run time. Clicking on a column's header at run time will not sort the grid and the sort indicator is not visible in the column header. For more information about column sorting, see the Sorting Columns topic.