[SOLVED] Unselect a listviewitem

Answered
0
0

If I call ListView.Items.RemoveAt(i) to remove a selected  item from a listview, it automatically selects the next item. I don’t want it to. How do I prevent that from happening, or make it unselect the current item?

I tried  this but it didn’t work.

 

Application.Update(lvIssues)
If Me.lvIssues.SelectedItems.Count > 0 Then
Me.lvIssues.SelectedItems(0).Selected = False
End If

 

 

 

  • You must to post comments
Best Answer
0
0

Thanks Andrew.

Logged as #1844

Best regards
Frank

  • Frank (ITG)
    Actually it´s not a bug and consistent to the behaviour in WinForms. After removing an item, the selection is empty. Regards, Frank
  • You must to post comments
0
0

Here is a sample.

 

  1. Right click an item in the middle somewhere
  2. Delete
  3. While the listview selects the next item, SelectedIndexChanged fires, but detects 0 items selected, showing the “null” in the preview panel
  • You must to post comments
0
0

I don’t have a sample for you at this time but this is related:

 

If I call .RemoveAt, it calls listview.SelectedIndexChanged.

The visual representation shows the next item selected, however, listview.SelectedItems.Count = 0.

Why would it show the selected item but still have Count = 0?

 

  • You must to post comments
0
0

Hi Andrew,

can´t reproduce, can you please share a test sample ?

Best regards
Frank

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.