This is a migrated thread and some comments may be shown as answers.

Sorting by DateTime

1 Answer 176 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 15 May 2012, 01:46 PM

Has anyone managed to sort a listview by a date rather than having the column taken to be a string?

I can't see a date specific entry so i'm currently using

ShareMessageListView.Columns.Add(new Telerik.WinControls.UI.ListViewDetailColumn("Date"));

This may be my problem.

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 17 May 2012, 02:13 PM
Hi Mat,

Thank you for contacting us.

Currently, RadListView does not support typed columns but it should sort the values according to their types and without taking them as strings. This might depend on the way you populate your list view with data. Your DateTime values might somehow get cast to string while populating the list view. The following code sample demonstrates how to add values to RadListView in order to be able to sort according to the DateTime values:
public Form1()
{
    InitializeComponent();
 
    this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
    this.radListView1.EnableColumnSort = true;
    this.radListView1.EnableSorting = true;
 
    for (int i = 0; i < 30; i++)
    {
        this.radListView1.Items.Add("asdf" + i, DateTime.Now.AddHours(i), "col 3", DateTime.Now.AddDays(i));
    }
}

I hope this will help you. If you continue experiencing difficulties, please send me a code snippet which demonstrates the way you setup the RadListView. This will help me provide you with a proper solution.

Kind regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
ListView
Asked by
Matt
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Share this question
or