Home > Software design >  How to keep the Selected property true when clicked a not exist row in ListView?
How to keep the Selected property true when clicked a not exist row in ListView?

Time:02-05

My ListView have to keep the Selected property true unless Light and Time value changed. (Because the ListView should remain in this state and Enabled should change to false.)

enter image description here

When I click outside ListView, the Selected property stays true. But, when I click a 'not exist' row of ListView, the Selected property doesn't stay true.

enter image description here

To solve this problem, I wrote a code in ListView_Click event, but ListView_Click event only occurs about rows with values.

What shoud I do?

CodePudding user response:

If you want to keep the selection locked to a specific item, and want to keep it highlighted no matter whether or not the form or the control has focus, do the following:

First, set listView1.HideSelection = false.

Then handle test result

  • Related