Multiple item list boxes

This is a discussion on Multiple item list boxes within the Windows Programming forums, part of the Platform Specific Boards category; Hey, does anyone know where I can find a tutorial on multiple item list boxes. Like some programs have a ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    112

    Multiple item list boxes

    Hey, does anyone know where I can find a tutorial on multiple item list boxes. Like some programs have a list box and at the top are buttons and when you click on them it arranges the list box alphabetically for that item.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    The class CListbox stores its data in a data structure. You can use a temporary C++ data struct such as a vector, list, stack, or queue to arrange the data in any way you want. All you do is update the data in the listbox.

    For example:

    -----

    CListbox cBox;

    int i = cBox.AddString("Two");
    cBox.SetItemData(i, 2);
    i = cBox.AddString("Three");
    cBox.SetItemData(i, 3);
    i = cBox.AddString("One");
    cBox.SetItemData(i, 1);

    -----

    The cBox lists the information as:

    Two
    Three
    One

    If you want it to output,

    One
    Two
    Three

    then you can copy those data into another data structure and rearrange the data. Update cBox once you are done.

    ResetContent() clears the listbox. Use that and then reinsert the data.

    As for the button on top of the list, that is just a standard button. Add a button and map an on-click message.

    Kuphryn

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    What you are describing sounds like a list view common control. Novacain has provided some code to configure one specifically as you have described (win32) here:

    http://www.cprogramming.com/cboard/s...threadid=14594

    The equivalent class object in mfc is a CListView.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-28-2008, 12:24 AM
  3. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 12:52 PM
  4. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 01:21 PM
  5. Replies: 6
    Last Post: 03-02-2005, 02:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21