Rick Kriscka

I have a CListCtrl and I want a particular row selected, this this example row 4.

int row = 3;

SetItemState(row, LVIS_SELECTED, LVIS_SELECTED);

This does select the row and treats it as selected, BUT it does not look selected (it is not highlighted in the view). How do I highlight a particular row so that it looks selected



Re: Visual C++ General CListCtrl - ReportView - Selecting a row

Viorel.

Probably the list control shows item as selected only when it is focused. In order to display selected items even if not focused, try the "Always show selection" style for control in Resource Editor. I hope this helps.

 





Re: Visual C++ General CListCtrl - ReportView - Selecting a row

Marius Bancila

Yes, the control list needs focus to show selection, but the behaviour changes if flag LVS_SHOWSELALWAYS is used.




Re: Visual C++ General CListCtrl - ReportView - Selecting a row

Rick Kriscka

Viorel -

Thank you very much, it would have taken me forever to figure that out on my own. I was just not connecting those two pieces. I am satisfied with those results.

Just out of curiousity if you know, a regular selected line appears with a black background and white text, where this shows a grey background with black text. Do you know why there is a difference





Re: Visual C++ General CListCtrl - ReportView - Selecting a row

Viorel.

 Rick Kriscka wrote:
[...]

Just out of curiousity if you know, a regular selected line appears with a black background and white text, where this shows a grey background with black text. Do you know why there is a difference

I think this is by design. Grey colour says that the list control currently has no focus. Background becomes black when the control is focused.