Help with CListBox Multi-column with checkbox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: Help with CListBox Multi-column with checkbox

Hybrid View

  1. #1
    Join Date
    Oct 2005

    Help with CListBox Multi-column with checkbox

    Hi All,

    Firstly I've managed to put together a mockup image of what I'm after, it's attached and what I have with code so far is below.

    I'm not particlurly fluent in C++ but a fast learner. The following is what I am attempting to achieve:
    1. I'm trying to create this multiple column List with checkboxes in the second column of the items.
    2. Where the second column heading is I'd like to place a image instead of text.
    3. How to check these boxes.
    4. How to disable the boxes.

    Any help is greatly appreciated!

    //******Somehow here insert column heading with image *******
    //m_myListControl.InsertColumn(2,??An image??LVCFMT_LEFT,50);

    CString strText;

    // Insert 10 items in the list view control.
    for (int i=0;i < 10;i++)
    m_myListControl.InsertItem(LVIF_TEXT|LVIF_STATE, i, "Layer Title", 0, 0, 0, 0);
    //*******here somehow add a checkbox on the second column******
    m_myListControl.SetItemText(i, 1, "CHECKBOX");
    m_myListControl.SetItemText(i, 2, "'WS Point: '+AssetType");
    m_myListControl.SetItemText(i, 3, "(0, 10000)");

    //*******On the 5th item check checkbox and disable it******
    if (i = 4)
    //I know this isn't right but hopefully you'll see what mean
    Attached Images Attached Images  
    Last edited by ill_comms; March 16th, 2009 at 10:48 AM.

  2. #2
    Join Date
    Jun 2002
    Stockholm, Sweden

    Re: Help with CListBox Multi-column with checkbox


    1. The checkbox can only be in the first column, but you can use SetColumnOrderArray to (visually) make it appear in the second column.

    2. There should be many samples available. Look at this:

    3. Use
    ListView_SetItemState (ListCtrl.m_hWnd, i, 
              UINT((int(checked) + 1) << 12), LVIS_STATEIMAGEMASK); // checked=1 or 0 will check/uncheck the item
    4. No idea.
    Edit: Possibly this could help:
    Last edited by zerver; March 16th, 2009 at 11:30 AM.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Oct 2005

    Re: Help with CListBox Multi-column with checkbox

    Hi Zerver,

    thanks, I'll check out all your suggestions in a second.

    thought I might just throw this one into the mix. Coming up soon I have a similar little project which requires multiple checkboxes in multiple columns, does anyone have anyone ideas on how something like this could be accomplished.

    Regards Hayden

  4. #4
    Join Date
    Oct 2005

    Re: Help with CListBox Multi-column with checkbox [SOLVED]

    Hi Zerver,

    Thanks again for your help, as it was a fairly open ended question you gave me the answer for me to solve a majority of my issues.

    In the end I found a project that was close enough to what I wanted that I could slightly alter to fit my needs.

    Project: CheckLCDemo

    Regards Hayden

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center