The color of the selected item in the ListView

I am writing listView1.Items [1] .Selected = true; but he does not highlight this subject .... what is wrong? I also changed the HideSelection property to False, so now at least I can see the gray color of the selection, but where is the blue color? when I click "Mouse", it is blue, but when I install it with the code above, it is not blue ... what am I doing wrong?

+3
source share
2 answers

These are your Windows colors that fool you.
I just tested it, and with HideSelectionset to false, I set the selected item and I see that this item is turning gray, which is my Windows color definition for the selected item in an inactive control.
If you want it to turn blue, which is most likely the color of the selected item in the active control, set the focus to ListView, saying listView1.Focus(), and you will see the color that you are talking about, but you just focused on it, so be careful.

+3
source
listView1.Select();
listView1.Items[index].Selected = true;
+2
source

Source: https://habr.com/ru/post/1773722/


All Articles