System.NullReferenceException: 'Object reference not set to an instance of an object.' when removing items from the list:
public Form1()
{
InitializeComponent();
for (var i = 0; i < 30; i++)
{
var item = new ListViewDataItem();
radListView2.Items.Insert(0, item);
item[0] = i;
item[1] = i;
item[2] = i;
item[3] = i;
}
}
private void radButton1_Click(object sender, EventArgs e)
{
try
{
radListView2.BeginUpdate();
foreach (var lvi in radListView2.Items.ToArray())
{
radListView2.Items.Remove(lvi);
}
}
finally
{
radListView2.EndUpdate();
}
}
Hello, Stoyan,
I would like to follow up on this. Our developers are working on this issue and when the testing process is complete we would be able to introduce a fix in our upcoming LIB scheduled for next week. Make sure that you follow the feedback item in order to get notified when its status has changed. Thus, you should be able to download it from your Telerik account and test locally how it works with the fix.
I hope this information is useful. Please let me know if you have other questions.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Unfortunately, the workaround does not bring the necessary performance gain.
13 sec is a lot. Same code on standard ListView takes only 4 sec and only 0.13 sec with BeginUpdate() / EndUpdate().
radListView2.Items.Clear() is not an option, as in real case i have to remove only certain Items (most of them).
Hi, Stoyan,
To workaround use the SuspendLayout/ResumeLayout code block:
private void radButton1_Click(object sender, EventArgs e)
{
try
{
radListView2.SuspendLayout();
foreach (var lvi in radListView2.Items.ToArray())
{
radListView2.Items.Remove(lvi);
}
}
finally
{
radListView2.ResumeLayout();
}
}
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.