|
-
Jan 12th, 2003, 08:11 PM
#1
Thread Starter
Member
ListView Sorting on Clicked Column
Hi,
I have implemented the code from the following url:
Link to Sorting Code at Microsoft
to sort listview columns dynamically.
The pertinant piece of code is:
' Determine whther the type being comapared is a date type
Try
' Parse the two objects into Datetime.
Dim firstdate As System.DateTime = DateTime.Parse(CType(x, ListViewItem).SubItems(col).Text)
Dim seconddate As System.DateTime = DateTime.Parse(CType(y, ListViewItem).SubItems(col).Text)
' Compare the two dates
returnval = DateTime.Compare(firstdate, seconddate)
' If neither compared objects has a valid date format, compare it as a string
Catch
' String Compare the two objects
returnval = [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
End Try
Trouble is, the data is some of my columns is null and causes the error:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
Does anyone know how to make it work when there are nulls in the columns?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|