Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a CListCtrl, how can I make selection color entire row?

Tags:

mfc

clistctrl

I currently have NM_CUSTOMDRAW message calling a function to color the rows of a listctrl in report mode. I can detect when a row is selected and color it myself, but this method doesn't get called for the cell that is selected, so I can't color that cell. So my question is 1) is there a way to have windows call my custom draw method for every cell whether it is selected or not? 2) If not what is the easiest way to make a selection span entire row. Thanks, CP

like image 472
CptanPanic Avatar asked Oct 30 '25 17:10

CptanPanic


1 Answers

I found the answer, and Microsoft made it easier than I guess it used to be.

m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);

See:

https://learn.microsoft.com/en-gb/windows/win32/controls/extended-list-view-styles?redirectedfrom=MSDN

LVS_EX_FULLROWSELECT

When an item is selected, the item and all its subitems are highlighted. This style is available only in conjunction with the LVS_REPORT style.

like image 196
CptanPanic Avatar answered Nov 04 '25 02:11

CptanPanic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!