CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Location
    CA , USA
    Posts
    83

    Unhappy 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

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    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

  3. #3
    Join Date
    Apr 2001
    Location
    CA , USA
    Posts
    83

    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

  4. #4
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382
    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
  •  





Click Here to Expand Forum to Full Width

Featured