Note that there are some explanatory texts on larger screens.

plurals
  1. POObjectListView: Custom Sorter
    primarykey
    data
    text
    <p>In the control ObjectListView(<a href="http://objectlistview.sourceforge.net/html/cookbook.htm" rel="nofollow noreferrer">http://objectlistview.sourceforge.net/html/cookbook.htm</a>), I'm trying to add a custom sorter where it ignores "The" and "A" prefixes.</p> <p>I managed to do it with a regular ListView, but now that I switched to ObjectListView(a lot more features, and ease), I can't seem to do the same.</p> <p>The following is the Main comparer in the ObjectListView code i think...</p> <pre><code>public int Compare(object x, object y) { return this.Compare((OLVListItem)x, (OLVListItem)y); } </code></pre> <p>Original Sorter for ascending, as an example (Ignoring "A" and "The")</p> <pre><code>public class CustomSortAsc : IComparer { int IComparer.Compare(Object x, Object y) { string[] px = Convert.ToString(x).Split(' '); string[] py = Convert.ToString(y).Split(' '); string newX = ""; string newY = ""; for (int i = 0; i &lt; px.Length; i++) { px[i] = px[i].Replace("{", ""); px[i] = px[i].Replace("}", ""); } for (int i = 0; i &lt; py.Length; i++) { py[i] = py[i].Replace("{", ""); py[i] = py[i].Replace("}", ""); } if ((px[1].ToLower() == "a") || (px[1].ToLower() == "the")) { if (px.Length &gt; 1) { for (int i = 2; i &lt; px.Length; i++) newX += px[i]; } } else { for (int i = 1; i &lt; px.Length; i++) newX += px[i]; } if ((py[1].ToLower() == "a") || (py[1].ToLower() == "the")) { if (py.Length &gt; 1) { for (int i = 2; i &lt; py.Length; i++) newY += py[i]; } } else { for (int i = 1; i &lt; py.Length; i++) newY += py[i]; } return ((new CaseInsensitiveComparer()).Compare(newX, newY)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload