P
Per Rollvang
Hi All!
Why have subitem sorting been removed? Or maybe not? Am I missing something?
Anyone?
Why have subitem sorting been removed? Or maybe not? Am I missing something?
Anyone?
Vanessa said:Your question is not so clear.
Per Rollvang said:Hi Vanessa!
I'm trying to implement sorting of listview-items, by other columns than the
first...
In VisualStudio 6.0 (the old common controls) this was as easty as to set a
property, but in .NET, this seem to be a big engineering project. Or am I
missing something...
-Per
derived from IComparer. Check your documentation for the ListView's classVas said:Yes you can sort by different columns, you have to create a class that's
strings, ints, and other stuff.Thanks a lot Vas!A crude example:
// call to immediately sort
listView.ListViewItemSorter = new ComparerClass(columnNumber);
// IComparer Class
class ComparerClass: IComparer
{
private int col;
public ComparerClass (int column) { col = column; }
public int Compare(object x, object y)
{
// cast items to strings
return string.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
}
}
You can add constructors to inform the sort whether its going to be