Hi I just tried to select an item in a listview by code. But there is no SelectedIndex property.

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

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?

  • You must to post comments
0
0

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

  • You must to post comments
0
0

Hi Gunter,

the bug is logged as WJ-7755, fixed and will be in the next release, most likely published tomorrw.

Thanks
Frank

  • You must to post comments
0
0

Thanks Gunter.

I could reproduce the problem. We´ll check and notify when the fix is available.

Best regards
Frank

  • You must to post comments
0
0

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

Attachment
  • You must to post comments
0
0

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.

  • You must to post comments
0
0

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. http://wisej.com/docs/html/Properties_T_Wisej_Web_ListView.htm

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

  • Tiago (ITG)
    I don’t think there should be a SelectedIndex property since you may select more than one item.
  • Luca (ITG)
    That’s probably why WinForms doesn’t have it. However, the ListBox has the SelectedIndex property and the option to have multiple selection. I’m not sure if the ListBox.SelectedIndex is -1 when there are multiple items or if it indicates the first – have to check.
  • You must to post comments
Showing 6 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json