-
October 18th, 2002, 02:19 PM
#1
adding check box to clistctrl
hi
I have a list control which has the LVS_EX_CHECKBOXES style.
im inserting the colum using InsertColumn and LV_COLUMN structure.
like shown below
Code:
LV_COLUMN Column;
Column.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH |LVCF_IMAGE ;
Column.cx = 20;
Column.cchTextMax = 10;
Column.iSubItem = 0;
Column.pszText = "Image#";
InsertColumn (0, &Column);
im using InsertItem to fill the list using LV_ITEM structure. something like shown below
Code:
LV_ITEM FieldData;
FieldData.iItem = iItem;
FieldData.mask = LVIF_TEXT|LVIF_IMAGE ;
FieldData.iSubItem = 0;
FieldData.pszText = (char*)(LPCSTR)strImageNo;
FieldData.cchTextMax = strImageNo.GetLength ();
i can see the check boxes coming but im not able to set them . I want to set the check boxes programatically
im using
ListView_SetItemState( handle, CurrentItem,
INDEXTOSTATEIMAGEMASK(2), LVIS_STATEIMAGEMASK);
but still i dont see the check boxes coming as checked.
Any help is greately appreciated
Thanks
shashi
-
October 18th, 2002, 03:36 PM
#2
Eran Yariv posted an article on checkboxes at Code Project. Here is the solution and link to the article.
Code:
void SetLVCheck (WPARAM ItemIndex, BOOL bCheck)
{
ListView_SetItemState (m_lvTestList.m_hWnd, ItemIndex, UINT((int(bCheck) + 1) << 12), LVIS_STATEIMAGEMASK);
}
http://www.codeproject.com/listctrl/listcheckbox.asp
Kuphryn
-
October 18th, 2002, 04:09 PM
#3
i have seen that post
hi
i have refered that post but its not working for me.
void SetLVCheck (WPARAM ItemIndex, BOOL bCheck)
{
ListView_SetItemState (m_lvTestList.m_hWnd, ItemIndex,
UINT((int(bCheck) + 1) << 12), LVIS_STATEIMAGEMASK);
}
is not working
thanks
shashi
-
October 19th, 2002, 08:25 PM
#4
ListView_SetCheckState() is usually used to set and clear the checkboxes. Have you tried that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|