ComponentOne Grid for WPF: Grid for WPF Task-Based Help > Controlling Grid Interaction > Preventing a Column from Being Sorted

Preventing a Column from Being Sorted

You can easily prevent a column in the grid from being sorted by using the AllowSort property. By default the AllowSort property is set to True and sorting is allowed. By setting the AllowSort property False, you can prevent users from sorting a column in the grid.

In XAML

Prevent users from sorting the ProductName column at run time by adding AllowSort="False" to the <c1grid:Column> tag so that it looks similar to the following:

<c1grid:Column PropertyName="ProductName" Caption="Name" AllowSort="False"/>In Code

Prevent users from sorting the ProductName column at run time by adding the following code to your project:

      Visual Basic

C1DataGrid1.Columns("ProductName").AllowSort = False

      C#

c1DataGrid1.Columns["ProductName"].AllowSort = false;


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.