List box help

This is a discussion on List box help within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I am trying to use a list box control in a dialog based app and I want to format ...

  1. #1
    Registered User Dohojar's Avatar
    Join Date
    Feb 2002
    Posts
    115

    List box help

    Hello,
    I am trying to use a list box control in a dialog based app and I want to format the output that is displayed in the list box like so:

    Code:
     Item description                                   cost         tax
     first item here                                   $22.00       $1.00
     next item here                                    $22.00       $1.00
    but I cant get the strings to line up properly under the headings because the font is a variable size. so I end up with something like this:

    Code:
     Item description                                   cost           tax
     first item here                                        $22.00       $1.00
     next item here                               $22.00       $1.00
     anouther item here                            $22.00       $1.00
    it depends on the characters used in the description how the string is displayed.Does anyone know how I can deal with this cause I am at a loss. the only other thing I can think of to do is make a differnt list boxes for each catagory and use one scroll bar for all 3 listboxes so that way the everything lines up. But can you send a scroll notification to a list box so that it will scroll up or down one line? Not sure how to do it. if anyone can help I would sure appreciate it.
    Dohojar Moajbuj
    Time is the greatest teacher, too bad it kills all its students

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    You can....

    1) Use a fixed width font, such as courier.

    or...

    2) Use a listview instead of a listbox, which supports columns exactly how you describe you want them.

  3. #3
    Registered User Dohojar's Avatar
    Join Date
    Feb 2002
    Posts
    115
    thanks I will give that a go and see what happens
    Dohojar Moajbuj
    Time is the greatest teacher, too bad it kills all its students

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Create your list box with the LBS_USETABSTOPS style, you can then line up your text with TAB characters.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Registered User Dohojar's Avatar
    Join Date
    Feb 2002
    Posts
    115
    I will play with that as well. I got it to work with a fixed font but looks kinda ugly.
    Dohojar Moajbuj
    Time is the greatest teacher, too bad it kills all its students

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-27-2008, 11:24 PM
  2. Recursion Revisited again, and again!
    By clegs in forum C++ Programming
    Replies: 93
    Last Post: 12-08-2007, 07:02 PM
  3. List box horizontal bar
    By cfriend in forum Windows Programming
    Replies: 1
    Last Post: 09-12-2004, 03:52 PM
  4. Linked List
    By jpipitone in forum C Programming
    Replies: 4
    Last Post: 03-30-2003, 08:27 PM

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