Thread: Multiple item list boxes

  1. #1
    Registered User
    Join Date
    Mar 2002

    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
    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:


    If you want it to output,


    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.


  3. #3
    Join Date
    Jan 2002
    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:

    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-27-2008, 11:24 PM
  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