Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable/Hide Items in a CListCtrl MFC

Tags:

c++

mfc

clistctrl

I want to hide or disable Items with SetItemState(). The CListCtrl is in Report View. It must be something like this m_List.SetItemState(1, DISABLE, DISABLE);

I searched but didnt find the right nState

If there is another solution than SetItemState, it also will be ok

Can anyone help me?

like image 681
user2675121 Avatar asked Jul 19 '26 16:07

user2675121


1 Answers

There is no item state to represent a disabled (grayed) item. See docs The only way to solve this is your own implementation and using custom draw. That is the way I do it.

You can easily prevent the user to select an item when you trap LVN_ITEMCHANGING. Just filter the state Change to LVIS_SELECTED and return TRUE to prevent the change.

like image 87
xMRi Avatar answered Jul 22 '26 06:07

xMRi



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!