S
sonu
Hi,
I have a problem regarding use of a ListviewSorter class which is used
to sort the items in the
listview.
Basically I have a listview with three columns as "Name","Size" and
"Date/Time" having datatype as text,Integer and datetime.
I need to sort the values in the listview depending upon whicj column
is currently clicked.
The problem is while sorting the integer values.
Function for comparing the values is something like.
Public Function Compare(ByVal x As Object, ByVal y As Object) As
Integer Implements System.Collections.IComparer.Compare
listViewItem1 = CType(x, ListViewItem)
listViewItem2 = CType(y, ListViewItem)
If columnToSort = ListColumn.NAME Then 'compare the two data depending
upon text values
compareResult =
ObjectCompare.Compare(listViewItem1.SubItems(columnToSort).Text,
llistViewItem2.SubItems(columnToSort).Text)
ElseIf columnToSort = ListColumn.SIZE Then 'compare the two data
depending upon numeric values
compareResult = Val(listViewItem1.SubItems(columnToSort).Text) >
Val(listViewItem2.SubItems(columnToSort).Text)
... code to compare dates
If OrderOfSort = SortOrder.Ascending Then
Return compareResult 'Ascending sort is selected, return
normal result of compare operation
ElseIf OrderOfSort = SortOrder.Descending Then
Return (-compareResult) 'Descending sort is selected,
return negative result of compare operation
Else
Return 0
End If
End function
My listview gets sort only once when selected the option sort by size
What could be the problem ..
Thanks in advance
I have a problem regarding use of a ListviewSorter class which is used
to sort the items in the
listview.
Basically I have a listview with three columns as "Name","Size" and
"Date/Time" having datatype as text,Integer and datetime.
I need to sort the values in the listview depending upon whicj column
is currently clicked.
The problem is while sorting the integer values.
Function for comparing the values is something like.
Public Function Compare(ByVal x As Object, ByVal y As Object) As
Integer Implements System.Collections.IComparer.Compare
listViewItem1 = CType(x, ListViewItem)
listViewItem2 = CType(y, ListViewItem)
If columnToSort = ListColumn.NAME Then 'compare the two data depending
upon text values
compareResult =
ObjectCompare.Compare(listViewItem1.SubItems(columnToSort).Text,
llistViewItem2.SubItems(columnToSort).Text)
ElseIf columnToSort = ListColumn.SIZE Then 'compare the two data
depending upon numeric values
compareResult = Val(listViewItem1.SubItems(columnToSort).Text) >
Val(listViewItem2.SubItems(columnToSort).Text)
... code to compare dates
If OrderOfSort = SortOrder.Ascending Then
Return compareResult 'Ascending sort is selected, return
normal result of compare operation
ElseIf OrderOfSort = SortOrder.Descending Then
Return (-compareResult) 'Descending sort is selected,
return negative result of compare operation
Else
Return 0
End If
End function
My listview gets sort only once when selected the option sort by size
What could be the problem ..
Thanks in advance