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?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.