Click here to Skip to main content
16,016,962 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, everyone!
I need something for listctrl.
I want to put a check box in listctrl and decide whether to display or hide each row depending on whether or not the check box is checked.
Do you have a library with the appropriate functions?
If not, how would you like it to be implemented?
My idea was to set the height of the line to zero, but I don't even know how to change the height of each line.

What I have tried:

void RkwDListCtrl::OnItemChangeEvent(NMHDR* pNMHDR, LRESULT* pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);



	if (pNMLV->uChanged == LVIF_STATE && flag)
	{

		
		UINT nOldCheck = pNMLV->uOldState & LVIS_STATEIMAGEMASK;
		UINT nNewCheck = pNMLV->uNewState & LVIS_STATEIMAGEMASK;
		if (nOldCheck && nNewCheck && nOldCheck != nNewCheck)
		{

			BOOL bCheck = this->GetCheck(pNMLV->iItem);

			if (bCheck) {
				this->SetItemText(pNMLV->iItem, 14, "1");
			}
			else {
				this->SetItemText(pNMLV->iItem, 14, "");
			}

		}
	}

	*pResult = 0;
}
Posted
Updated 17-Nov-21 15:58pm

1 solution

I do not think changing the height will work. The main reason is I think you would have to draw each line yourself. I think the best way depends on how (and if) you are storing the data. If you have all the data in some sort of collection then it is simple to just delete rows that are not visible and you can always restore them if you need to. That is actually the most important point - do you need to put and items back in the last to be displayed? If not then you can just remove any selected lines from the list control by calling DeleteItem. If you will need to restore any data then you will have to save it somewhere when it is removed from the control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900