A
> Adrian
In VS 2003 I could sort a column in a list view using the code below,
hover, in V2005 I get this error:
Error 1 Using the generic type 'System.Collections.Generic.IComparer<T>'
requires '1' type arguments
What to do?
Please tell me concretely how to get rid of this error in terms of code.
Many thanks,
Adrian
private void ColumnClick(object o, ColumnClickEventArgs e)
{
// Set the ListViewItemSorter property to a new
ListViewItemComparer object.
this.listView1.ListViewItemSorter = new
ListViewItemComparer(e.Column);
// Call the sort method to manually sort the column based on the
ListViewItemComparer implementation.
listView1.Sort();
}
// Implements the manual sorting of items by columns.
class ListViewItemComparer : IComparer ****error line***
{
private int col;
public ListViewItemComparer()
{
col = 0;
}
public ListViewItemComparer(int column)
{
col = column;
}
public int Compare(object x, object y)
{
return String.Compare(((ListViewItem)x).SubItems[col].Text,
((ListViewItem)y).SubItems[col].Text);
}
}
hover, in V2005 I get this error:
Error 1 Using the generic type 'System.Collections.Generic.IComparer<T>'
requires '1' type arguments
What to do?
Please tell me concretely how to get rid of this error in terms of code.
Many thanks,
Adrian
private void ColumnClick(object o, ColumnClickEventArgs e)
{
// Set the ListViewItemSorter property to a new
ListViewItemComparer object.
this.listView1.ListViewItemSorter = new
ListViewItemComparer(e.Column);
// Call the sort method to manually sort the column based on the
ListViewItemComparer implementation.
listView1.Sort();
}
// Implements the manual sorting of items by columns.
class ListViewItemComparer : IComparer ****error line***
{
private int col;
public ListViewItemComparer()
{
col = 0;
}
public ListViewItemComparer(int column)
{
col = column;
}
public int Compare(object x, object y)
{
return String.Compare(((ListViewItem)x).SubItems[col].Text,
((ListViewItem)y).SubItems[col].Text);
}
}