Can't add ListViewDataItem after Column Sort

3 posts, 1 answers
  1. Brandon
    Brandon avatar
    17 posts
    Member since:
    Sep 2011

    Posted 26 Mar 2012 Link to this post

    I have enabled Sorting and Column Sorting under the Telerik ListView properties.

    This ListView is updated on a regular interval. In the update method I call Items.Clear() and Columns.Clear().
    I add some columns programmitically as well. However, when the code runs below it throws an "Out of range index" exception.

    radListView.Items.Add(new ListViewDataItem(dr["Mon"].ToString() + dr["Year"].ToString()));
    ListViewDataItem item = this.radListView.Items[0];

    This only occurs after I have clicked a column header to sort it. If the column was not sorted, the code runs fine.
    When I look at the Count of radListView.Items the Count is 0. This means the radListView.Item.Add method did nothing..
  2. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 30 Mar 2012 Link to this post

    Hi Brandon,

    Thank you for contacting us.

    Despite my efforts I was not able to reproduce this exception. Generally, after you have added an item to the Items collection, it will not appear in it if the filtering is enabled and you have added a filter rule that excludes this item (the item will appear later when you either disable filtering or change the filter descriptors). However, I am not sure if this is the case since the code you have provided is not sufficient. Therefore, I would kindly ask you to open a new support ticket and send me a sample project which demonstrates the exception. Alternatively, you can post the full source code of the sample project here in this thread. This will let me investigate the scenario and provide you with adequate support.

    I am looking forward to hearing from you.

    Greetings,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brandon
    Brandon avatar
    17 posts
    Member since:
    Sep 2011

    Posted 02 Apr 2012 Link to this post

    Ivan was able to help with this when I submitted a support ticket. Below is the answer.
    ListViewDataItem item = new ListViewDataItem(dr["TP_MON"].ToString() + dr["TP_Year"].ToString());
    radlistview.Items.Add(item);
Back to Top