Insert item

3 posts, 1 answers
  1. Øystein Olsen Holt
    Øystein Olsen Holt avatar
    3 posts
    Member since:
    Feb 2010

    Posted 09 Mar 2012 Link to this post

    Hi!

    I'm trying to insert a single item in a DataList, but i only get a null point exception (Object reference not set to an instance of an object..) If i "add" the same item first and then "insert" it's working, but not with insert alone...

    This is not working:
    lvServiceResult.Items.Insert(0, new ListViewDataItem(text + @"..."));

    This is working:
    lvServiceResult.Items.Add(new ListViewDataItem(text + @"..."));
    lvServiceResult.Items.Insert(0, new ListViewDataItem(text + @"..."));

    Any ideas?

    BR,
    Erlend Haukland
  2. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 13 Mar 2012 Link to this post

    Hello Erlend,

    Thank you for contacting us.

    This appears to be an issue in RadListView. I have logged it in our Public Issue Tracking System so you can subscribe to it and track it for changes. Here is the link to the PITS item. We will address this issue in a next release.

    For the time being, I can suggest either the workaround you have found or calling the SuspendLayout and ResumeLayout methods respectively before and after inserting the item:
    this.radListView1.RootElement.SuspendLayout(true);
    this.radListView1.Items.Insert(0, new ListViewDataItem(text + @"..."));
    this.radListView1.RootElement.ResumeLayout(true, true);

    Your Telerik points have been updated for reporting this issue.

    Should you have additional questions, do not hesitate to ask.

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Øystein Olsen Holt
    Øystein Olsen Holt avatar
    3 posts
    Member since:
    Feb 2010

    Posted 13 Mar 2012 Link to this post

    Hi again!

    The workaround works fine, so I'll just stick with that for the time being. Thanks for the answer.

    BR,
    Erlend Haukland
Back to Top