CustomSortingHandler
The method signature to your custom handler code that will set the property CustomComparerImplementor with your custom sorter object.
public delegate void CustomSortingHandler (object sender, ref bool CancelSortingNow, int ColumnClicked, string ClickedColumnName);
Remarks
The control (while in multi-column drop list mode) by default will support out-of-the-box sorting of column data as though they were items of type text.
If the column data happens to be a different type (for example numeric, or even custom types of yours), then you may want to sort that particular column data with your own sorting logic. If that is the case, then you can supply your own sorting implementation object by setting the property CustomComparerImplementor.
When a user clicks on a column, the control raises an event CustomSorting, which you can subscribe to, by attaching a custom handler of this delegate type (CustomSortingHandler.
This delegate will provide you with the information as to what column number has been clicked and its name. With this information in hand, you can easily decide whether you want to do a custom sorting using your own custom sorting logic.
In that case, all you need to do is to set the CustomComparerImplementor property with your custom sorting implementation (which should implement IComparer interface.
Once you provide your custom sorting implementation by setting the CustomComparerImplementor property, the control will use your custom sorting implementation to sort that particular column data (i.e. the column that has just been clicked by the user). If you don't provide a custom IComparer sorting implementation, the control will use the default built-in sorting implementation, which will basically consider the clicked column data as being of type text (simple string) and accordingly sort it as such.
The following code example will make this clear: (Example in C# language): ... other code ... ... other code ... // Attaching a custom handler to the event "CustomSorting" that will be raised when a user clicks on a column this.binaryTextComboBoxInstance.CustomSorting += new Binarymission.WinForms.Controls.ListControls.BinaryTextComboBox.CustomSortingHandler(this.binaryTextComboBoxInstance_CustomSorting); ... other code ... ... other code ... // Your sample custom sorting implementation public class NumericSorter : IComparer { private int theColumn = 0; public NumericSorter(int aColumn) { theColumn = aColumn; } public int Compare(object x, object y) { Int32 theint_a = Convert.ToInt32(((ListViewItem)x).SubItems[theColumn].Text, 16); Int32 theint_b = Convert.ToInt32(((ListViewItem)y).SubItems[theColumn].Text, 16); return (theint_a > theint_b) ? 1 : 0; } } private void binaryTextComboBoxInstance_CustomSorting(object sender, ref bool CancelSortingNow, int ColumnClicked, string ColumnName) { // if you want to cancel sorting the column at this point, please set the "CancelSortingNow" parameter to true. Otherwise leave it as it is - since by default it is false. CancelSortingNow = false; if(ColumnClicked == 3 || ColumnName == "Project Count") // this will ensure the control will use your custom sorter implementation this.binaryTextComboBoxInstance.CustomComparerImplementor = new NumericSorter(3); else // this will ensure the control will use the default built-in sorter logic (i.e. string based sorting) this.binaryTextComboBoxInstance.CustomComparerImplementor = null; } <param name="sender">This is an instance of BinaryTextComboBox class</param> <param name="CancelSortingNow">A boolean type. Set this to true if you want to cancel sorting the clicked column.</param> <param name="ColumnClicked">The column number that has been clicked by the user.</param> <param name="ClickedColumnName">The text of the column header that has been clicked by the user.</param>
Note: To be able to use this delegate, the EnableColumnSorting property must have been set to true.