Selecting an item in RadListView

1 Answer 98 Views
ListView
Matt
Top achievements
Rank 1
Matt asked on 16 Nov 2022, 06:54 PM

In the ItemCheckedChanged event, I want to also select the item, yet the following assignment returns the error "The property or indexer 'ListViewDataItem.Selected' cannot be used in this context because the set accessor is inaccessible."

e.Item.Selected = true;

How do I do this?

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 17 Nov 2022, 09:24 AM

Hello Matt,

You can use the Select method of the RadListView to select items programmatically. Check the following code snippet.

public Form1()
{
    InitializeComponent();
    this.radListView1.ItemCheckedChanged += RadListView1_ItemCheckedChanged;
    this.radListView1.ShowCheckBoxes = true;
}

private void RadListView1_ItemCheckedChanged(object sender, Telerik.WinControls.UI.ListViewItemEventArgs e)
{
    ListViewDataItem[] itemsToSlelct = new ListViewDataItem[1];
    itemsToSlelct[0] = e.Item;
    radListView1.Select(itemsToSlelct);
}

Regards,
Dinko | Tech Support Engineer
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/.

Tags
ListView
Asked by
Matt
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or