Reputation: 191
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?
Upvotes: 3
Views: 5441
Reputation: 4335
You can give visual feedback. I would derive a class CMFCListCtrl
and override OnGetCellBkColor
and OnGetCellTextColor
methods to achieve it.
And I would override the its response to selection to unselect when selecting an unselectable item. However for this part, I am not so sure if it is doable.
Upvotes: 0
Reputation: 15375
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.
Upvotes: 4