CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    27

    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!
    Hayden


    m_myListControl.InsertColumn(1,"Layer",LVCFMT_LEFT,50);
    //******Somehow here insert column heading with image *******
    //m_myListControl.InsertColumn(2,??An image??LVCFMT_LEFT,50);
    //**********************************************
    m_myListControl.InsertColumn(3,"Zoom",LVCFMT_LEFT,50);
    m_myListControl.InsertColumn(4,"Labels",LVCFMT_LEFT,50);
    m_myListControl.SetColumnWidth(0,200);
    m_myListControl.SetColumnWidth(1,20);
    m_myListControl.SetColumnWidth(2,100);
    m_myListControl.SetColumnWidth(3,100);

    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
    m_myListControl.SetCheck(2,1);
    m_myListControl.SetDisabled(2,1);
    }
    }
    Attached Images Attached Images  
    Last edited by ill_comms; March 16th, 2009 at 09:48 AM.

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Help with CListBox Multi-column with checkbox

    Hi!

    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: http://www.codeguru.com/forum/archiv.../t-169249.html

    3. Use
    Code:
    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: http://209.85.129.132/search?q=cache...&hl=en&ct=clnk
    Last edited by zerver; March 16th, 2009 at 10:30 AM.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Oct 2005
    Posts
    27

    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
    Posts
    27

    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
    http://en.pudn.com/downloads78/sourc...297923_en.html

    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
  •  





Click Here to Expand Forum to Full Width

Featured