This is a migrated thread and some comments may be shown as answers.
Insert item
2 Answers 61 Views
This is a migrated thread and some comments may be shown as answers.
Øystein Olsen Holt
Top achievements
Rank 1
Øystein Olsen Holt asked on 09 Mar 2012, 10:10 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 13 Mar 2012, 10:26 AM
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 >>
0
Øystein Olsen Holt
Top achievements
Rank 1
answered on 13 Mar 2012, 10:37 AM
Hi again!

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

BR,
Erlend Haukland
Asked by
Øystein Olsen Holt
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Øystein Olsen Holt
Top achievements
Rank 1
Share this question
or