Re: List View Sorting Question
- From: "Ashot Geodakov" <a_geodakov@xxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 11:36:51 -0700
I see that you are trying to compare ListViewItems as Strings, so you need
to specify the string type as a generic type parameter:
class ListViewItemComparer : IComparer< string>
and you need to declare the Compare method with string as parameter type:
public int Compare(string x, string y)
"> Adrian <" <x@xxxxx> wrote in message
news:45e59e38$0$721$5fc3050@xxxxxxxxxxxxxxxxxxxxxxxxxxx
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);
}
}
.
- References:
- List View Sorting Question
- From: > Adrian <
- List View Sorting Question
- Prev by Date: Re: static member function, with no public/private/etc.
- Next by Date: Re: C# naming conventions (is m_varName used?)
- Previous by thread: List View Sorting Question
- Next by thread: DragOver vs DragEnter
- Index(es):