Back to Devexpress

GridOptionsCustomization.AllowSort Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridoptionscustomization-ca052ad0.md

latest6.9 KB
Original Source

GridOptionsCustomization.AllowSort Property

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

Declaration

csharp
[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowSort { get; set; }
vb
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property AllowSort As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true if end-users can apply data sorting; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to AllowSort
GridView

.OptionsCustomization .AllowSort

|

Remarks

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.

xaf-how-to-sort-a-listview-in-code/CS/XPO/SortListView/SortListView.Win/Controllers/WinSortListViewController.cs#L9

csharp
if(View.Editor is GridListEditor gridListEditor) {
    gridListEditor.GridView.OptionsCustomization.AllowSort = false;
}

winforms-grid-sql-pagination/CS/DxSample/MainForm.cs#L16

csharp
OrdersGridView.OptionsCustomization.AllowGroup = false;
OrdersGridView.OptionsCustomization.AllowSort = false;
OrdersGridView.OptionsFind.AllowFindPanel = false;

winforms-grid-move-focused-row-up-down/CS/Form1.cs#L198

csharp
gridView1.Columns[OrderFieldName].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
gridView1.OptionsCustomization.AllowSort = false;
gridView1.OptionsView.ShowGroupPanel = false;

winforms-grid-display-text-editor-in-column-header/CS/WindowsApplication1/MyGridColumnRenameHelper.cs#L63

csharp
{
    gridView.OptionsCustomization.AllowSort = false;
    headerEdit = new TextEdit();

winforms-grid-sql-pagination/VB/DxSample/MainForm.vb#L18

vb
OrdersGridView.OptionsCustomization.AllowGroup = False
OrdersGridView.OptionsCustomization.AllowSort = False
OrdersGridView.OptionsFind.AllowFindPanel = False

winforms-grid-move-focused-row-up-down/VB/Form1.vb#L196

vb
gridView1.Columns(OrderFieldName).SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
gridView1.OptionsCustomization.AllowSort = False
gridView1.OptionsView.ShowGroupPanel = False

winforms-grid-display-text-editor-in-column-header/VB/WindowsApplication1/MyGridColumnRenameHelper.vb#L60

vb
Private Sub Initialize()
    gridView.OptionsCustomization.AllowSort = False
    headerEdit = New TextEdit()

See Also

Sort Data in Code

AllowSort

EnableColumnMenu

OptionsColumn

AllowGroup

GridOptionsCustomization Class

GridOptionsCustomization Members

DevExpress.XtraGrid.Views.Grid Namespace