Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi everyone there,

I am developing a dialog based application in MFC and I have a CListCtrl with checkboxes. Code is as follows:

CListCtrl m_gridOutput;m_gridOutput.SetExtendedStyle(m_gridCtrlEx.GetExtendedStyle() | LVS_EX_CHECKBOXES);


I can track the changes in the ListControl but now I am trying to change the status of the Checkbox of an item. Unfortunately I am getting Assertion errors, when I try to use the following piece of code.

m_gridOutput.SetItem(1,0,LVIF_STATE,NULL,0,dwFlags,dwFlags,0);
(or)
ListView_SetItemState(m_gridOutput.GetSafeHwnd(),VarId,INDEXTOSTATEIMAGEMASK((fCheck)+ 1), LVIS_STATEIMAGEMASK);
(or)
ListView_SetCheckState((m_gridOutput.GetSafeHwnd(),Id,TRUE);


I want to add one more thing here. If I use SetCheck (or) ListView_SetCheckState in OnInitDialog(), it works fine. But if I try to use it in a seperate function, it gives assertion error. How to handle this?.

Any help is greatly appreciated.

Shiva
Posted
Updated 6-Apr-11 21:58pm
v3
Comments
Olivier Levrey 7-Apr-11 3:54am    
Don't repost an existing question!!
Smithers-Jones 7-Apr-11 4:00am    
Wow, you posted exactly the same thing 19 hours earlier. And you got two answers there. If there is anything unclear still, go back and improve your question, but do not post the same question again!

1 solution

An answer exists to this question:
MFC Error: Assertion Error in CListCtrl[^]
 
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