I have a grid with a month column where I have an .EditorComponent = UltraComboBox
The ComboBox has two columns Monthnumer and month name.
When I sort the grid on the month column it is sorted by month name(IE April comes first). I want the column to sort by month number instead (IE January first).
In the grid datasource the value fot the month column is the month number. Is there a way to make the grid ignore the displaymember proprerty of the combobox and sort on the value member instead.
Hello Jorbjo,
Thank you for your response.
The default behavior of the UltraGrid is to sort based on the text in the cell, as you've seen. If you want to sort a column based on something else, you will need to create a class that implements IComparer and set the SortComparer property of the column in question to an instance of that class. When the UltraGrid is ready to compare two cells, it will call your class's Compare() method and pass in the two cells as UltraGridCell objects.
Class MyCellComparer Implements IComparer Public Function Compare(x As Object, y As Object) As Integer Implements IComparer.Compare Dim cellX = CType(x, UltraGridCell) Dim cellY = CType(y, UltraGridCell) Dim valueX = CType(cellX.Value, Int32) Dim valueY = CType(cellY.Value, Int32) If valueX = valueY Then Return 0 ElseIf valueX < valueY Then Return -1 Else Return 1 End If End Function End Class
I'm Using Visual Studio 2012, VB and Infragistics 2012.2
Hello,
Thank you for contacting Infragistics. Which version of NetAdvantage are you using? It would also be helpful if you could tell me which version of Visual Studio you're using and which language you're programming in.