Back to Devexpress

CustomColumnSortEventArgs.Result Property

wpf-devexpress-dot-xpf-dot-grid-dot-customcolumnsorteventargs-1da38376.md

latest4.6 KB
Original Source

CustomColumnSortEventArgs.Result Property

Gets or sets the result of a custom comparison.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public int Result { get; set; }
vb
Public Property Result As Integer

Property Value

TypeDescription
Int32

An integer value that specifies the result.

|

Remarks

Use the Result property to set the result of the custom comparison of the two rows being processed. The compared values are returned by the CustomColumnSortEventArgs.Value1 and CustomColumnSortEventArgs.Value2 properties.

When handling the GridControl.CustomColumnSort event, the result must be set as follows:

  • Set Result to -1 if the first row should be positioned above the second row when data is sorted in ascending order. When data is sorted in descending order, the first row will be positioned below the second row.
  • Set Result to 1 if the first row should be positioned below the second row when data is sorted in ascending order. When data is sorted in descending order, the first row will be positioned above the second row.
  • Set Result to 0 to indicate that the rows are equal. In this case, the rows will be arranged within the grid according to their indices in a data source.

When handling the GridControl.CustomColumnGroup event, the result should be set as shown below:

  • Set Result to 0 , to indicate that the rows should be combined into the same group.
  • Set Result to 1 (or -1 ) to indicate that the rows should be placed in different groups.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Result 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.

wpf-data-grid-implement-custom-grouping/CS/CustomGrouping_CodeBehind/MainWindow.xaml.cs#L44

csharp
double y = Math.Floor(Convert.ToDouble(e.Value2) / 10);
e.Result = x > 9 && y > 9 ? 0 : x.CompareTo(y);
e.Handled = true;

wpf-data-grid-implement-custom-sorting/CS/CustomSorting_CodeBehind/MainWindow.xaml.cs#L44

csharp
int dayIndex2 = GetDayIndex(e.Value2);
e.Result = dayIndex1.CompareTo(dayIndex2);
e.Handled = true;

wpf-data-grid-implement-custom-grouping/VB/CustomGrouping_CodeBehind/MainWindow.xaml.vb#L44

vb
Dim y As Double = Math.Floor(Convert.ToDouble(e.Value2) / 10)
e.Result = If(x > 9 AndAlso y > 9, 0, x.CompareTo(y))
e.Handled = True

wpf-data-grid-implement-custom-sorting/VB/CustomSorting_CodeBehind/MainWindow.xaml.vb#L51

vb
Dim dayIndex2 As Integer = Me.GetDayIndex(e.Value2)
e.Result = dayIndex1.CompareTo(dayIndex2)
e.Handled = True

See Also

CustomColumnSortEventArgs Class

CustomColumnSortEventArgs Members

DevExpress.Xpf.Grid Namespace