Question exceptions in column sorting

Noremacam

Member
Joined
Jun 30, 2008
Messages
14
Programming Experience
1-3
I'm using the same method to sort my listview columns as here.

I want to sort a column of dates, but I have an exception. I'm pulling the dates from the database, and when they come back null, I replace the text with "Incomplete"(the dates are for completion dates). I thought this would save a column(not having to have a "complete?" column).

I want to sort by date, but I want my "incomplete"'s to come to the top of the list, ideally when sorting from most recent to oldest(but I'd take "all the time" too). How do I go about doing that? I'm stumped.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,334
Location
Norway
Programming Experience
10+
"incomplete" string is not a DateTime so you can't use DateTime.Compare with that. What you have to do is check if the string is "incomplete" and return an appropriate Integer value for those cases, else do DateTime.Compare as normal. IComparer.Compare documentation lists the appropriate Integer return values used for sorting.
 
Top Bottom