'Declaration Public Property FieldDisplayOrderComparer As IComparer(Of FieldItem)
public IComparer<FieldItem> FieldDisplayOrderComparer {get; set;}
If you want to display fields in a custom order then you can specify a comparer that the FieldChooser will use to determine the order in which to display the fields.
Imports Infragistics.Windows Imports Infragistics.Windows.Controls Imports Infragistics.Windows.Editors Imports Infragistics.Windows.DataPresenter Imports Infragistics.Windows.DataPresenter.Events Private Sub Dp_FieldChooserOpening(ByVal sender As Object, ByVal e As FieldChooserOpeningEventArgs) Dim fieldChooser As FieldChooser = e.FieldChooser ' You can use the FieldDisplayOrderComparer property to display fields ' in a custom order instead of the default alphabetical order. Set ' it to an object that implements IComparer<Field> and has the custom ' comparison logic that conveys the order of fields. fieldChooser.FieldDisplayOrderComparer = New CustomFieldOrderComparer() End Sub Private Class CustomFieldOrderComparer Implements IComparer(Of FieldItem) Private Function Compare(ByVal x As FieldItem, ByVal y As FieldItem) As Integer Implements IComparer(Of FieldItem).Compare ' Create a list of fields in the order in which you want to display ' them in the field chooser. Dim fieldsInOrder() As String = _ { _ "ID", _ "Product_Name", _ "Price", _ "Quantity", _ "Total", _ "Discount", _ "Net_Total" _ } ' Then use the indexes into the list for comparison. This effectively ' will cause the field chooser to display the fields in the same ' order as in the list above. Dim xIndex As Integer = Array.IndexOf(fieldsInOrder, x.Name) Dim yIndex As Integer = Array.IndexOf(fieldsInOrder, y.Name) Return xIndex.CompareTo(yIndex) End Function End Class
using Infragistics.Windows; using Infragistics.Windows.Controls; using Infragistics.Windows.Editors; using Infragistics.Windows.DataPresenter; using Infragistics.Windows.DataPresenter.Events; private void dp_FieldChooserOpening( object sender, FieldChooserOpeningEventArgs e ) { FieldChooser fieldChooser = e.FieldChooser; // You can use the FieldDisplayOrderComparer property to display fields // in a custom order instead of the default alphabetical order. Set // it to an object that implements IComparer<Field> and has the custom // comparison logic that conveys the order of fields. fieldChooser.FieldDisplayOrderComparer = new CustomFieldOrderComparer( ); } private class CustomFieldOrderComparer : IComparer<FieldItem> { public int Compare( FieldItem x, FieldItem y ) { // Create a list of fields in the order in which you want to display // them in the field chooser. string[] fieldsInOrder = new string[] { "ID", "Product_Name", "Price", "Quantity", "Total", "Discount", "Net_Total" }; // Then use the indexes into the list for comparison. This effectively // will cause the field chooser to display the fields in the same // order as in the list above. int xIndex = Array.IndexOf( fieldsInOrder, x.Name ); int yIndex = Array.IndexOf( fieldsInOrder, y.Name ); return xIndex.CompareTo( yIndex ); } }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2