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