windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridoptionscustomization-ca052ad0.md
Gets or sets a value specifying whether end-users can apply data sorting.
Namespace : DevExpress.XtraGrid.Views.Grid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowSort { get; set; }
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property AllowSort As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | true |
true if end-users can apply data sorting; otherwise, false.
|
You can access this nested property as listed below:
| Object Type | Path to AllowSort |
|---|---|
| GridView |
.OptionsCustomization .AllowSort
|
End-users can apply data sorting in two ways. First, by clicking a column header. The second is by right-clicking a column header and choosing the context menu’s Sort Ascending or Sort Descending item. If the AllowSort property value is true , both methods are available. Otherwise, end-users cannot apply data sorting.
If the AllowSort option is enabled, you can specify which column’s headers can be clicked to apply data sorting. The desired columns’ GridColumn.OptionsColumn property should be used for this purpose.
The column header context menu is available only when the View’s GridOptionsMenu.EnableColumnMenu option is enabled. Note that you can control which column headers can invoke this menu. Handle the GridView.PopupMenuShowing event for this purpose. Finally, you can implement custom menu item behavior by handling the GridView.GridMenuItemClick event.
Important note : data grouping requires sorting to be applied. Thus, disabling data sorting results in disabling grouping.
The following code snippets (auto-collected from DevExpress Examples) contain references to the AllowSort 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.
if(View.Editor is GridListEditor gridListEditor) {
gridListEditor.GridView.OptionsCustomization.AllowSort = false;
}
winforms-grid-sql-pagination/CS/DxSample/MainForm.cs#L16
OrdersGridView.OptionsCustomization.AllowGroup = false;
OrdersGridView.OptionsCustomization.AllowSort = false;
OrdersGridView.OptionsFind.AllowFindPanel = false;
winforms-grid-move-focused-row-up-down/CS/Form1.cs#L198
gridView1.Columns[OrderFieldName].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
gridView1.OptionsCustomization.AllowSort = false;
gridView1.OptionsView.ShowGroupPanel = false;
{
gridView.OptionsCustomization.AllowSort = false;
headerEdit = new TextEdit();
winforms-grid-sql-pagination/VB/DxSample/MainForm.vb#L18
OrdersGridView.OptionsCustomization.AllowGroup = False
OrdersGridView.OptionsCustomization.AllowSort = False
OrdersGridView.OptionsFind.AllowFindPanel = False
winforms-grid-move-focused-row-up-down/VB/Form1.vb#L196
gridView1.Columns(OrderFieldName).SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
gridView1.OptionsCustomization.AllowSort = False
gridView1.OptionsView.ShowGroupPanel = False
Private Sub Initialize()
gridView.OptionsCustomization.AllowSort = False
headerEdit = New TextEdit()
See Also
GridOptionsCustomization Class