Hi I just tried to select an item in alistview by code. But there is no SelectedIndex property, and also the property SelectedIndices does not provide a possibility. How do I do that?
Hello Gunter,
The ListView doesn’t have the SelectedIndex property (we should probably add it – it’s not in WinForms either) and the SelectedIndices and SelectedItems are read-only collections by design.
To select an item programmatically use the Selected property of the item: this.listView.Items[10].Selected = true. Look also at the SelectionMode and MultiSelect properties on the ListView. https://docs.wisej.com/api/wisej.web/lists-and-grids/listview
See https://msdn.microsoft.com/en-us/library/y4x56c0b(v=vs.110).aspx (you don need to set .Focused = true, use only .Selected = true)
HTH
Best,
Luca
Hi Frank
I just installed Version 1.3.5. When I set the selection by listView.Items[xx].Selected, on the selected item the background color is now properly set, but the orange border stays at the item recently selected by mouse click
Hi Gunter,
the bug is logged as WJ-7755, fixed and will be in the next release, most likely published tomorrw.
Thanks
Frank
Thanks Gunter.
I could reproduce the problem. We´ll check and notify when the fix is available.
Best regards
Frank
Hi Luca
But setting listView.Items[xx].Selected = true does not properly get to work. Wenn I set listView.Items[xx].Selected = true, the value is set, SelectedItems is also properly updated, but the selection mark is never set. Please see the test application attached
Hi Luca
You’re right, but I am migrating a VWG application, and in VWG there ist a property SelectedIndex and so I thougt it’s the same in winforms.