Sign in to follow this  
Followers 0
ca143508

ListView & Setting Column Types

3 posts in this topic

Morning Guys,

I am working on a new script using a listview to display the contents of a text file (see below). The problem that I am having is that I want to sort data in the listview in ascending order in the date column. However, when you click on the column heading, it is sorting by the first 2 numbers from the date, not the whole date itself. Is there a way that when I create the ListView I can specify the type of data in each column so that it can sort it correctly? Or am I better off breaking the date down somehow in order to get the sorting to work???

An Example of the text I want to use in the list view:

27/01/2007|Bill Gates|Microsoft Rules the World|8:00|16:00

16/02/2007|George Bush|I Rule the World|8:00|15:00

So when I sort by the date column, entry 1 should remain at the top. But at the moment, because 16 is before 27 it places that entry at the top, regardless of the fact it is a later date.

Any help you have would be appreciated.

Cheers

Mike.

Share this post


Link to post
Share on other sites



Morning Guys,

I am working on a new script using a listview to display the contents of a text file (see below). The problem that I am having is that I want to sort data in the listview in ascending order in the date column. However, when you click on the column heading, it is sorting by the first 2 numbers from the date, not the whole date itself. Is there a way that when I create the ListView I can specify the type of data in each column so that it can sort it correctly? Or am I better off breaking the date down somehow in order to get the sorting to work???

An Example of the text I want to use in the list view:

27/01/2007|Bill Gates|Microsoft Rules the World|8:00|16:00

16/02/2007|George Bush|I Rule the World|8:00|15:00

So when I sort by the date column, entry 1 should remain at the top. But at the moment, because 16 is before 27 it places that entry at the top, regardless of the fact it is a later date.

Any help you have would be appreciated.

Cheers

Mike.

ListView controls have a callback function for sorting, but you'd need to use a hook dll in order to use it. There are two other methods that you might want to condsider. The first would be to simply reformat your dates to yyyy/mm/dd. The second would be to turn off the automatic sorting, trap the notification messages when the columns are clicked and handle the sorting yourself. The first is trivial, the second is NOT. :whistle:

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

ListView controls have a callback function for sorting, but you'd need to use a hook dll in order to use it. There are two other methods that you might want to condsider. The first would be to simply reformat your dates to yyyy/mm/dd. The second would be to turn off the automatic sorting, trap the notification messages when the columns are clicked and handle the sorting yourself. The first is trivial, the second is NOT. :whistle:

Well done. Option 1 was exactly right. Can't believe I didn't think of it to start with. Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0