CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2010
    Posts
    13

    double header in a CListCtrl

    Hello

    i try to add two lines of header in a CListCtrl, is there a modified CListCtrl to do this ?

    For instance, i would like to have this
    Code:
    |                       zone 1                      |
    |         zone 2         |       zone 3        |
    ----------------------------------------------
    |             123          |         456           |
    -----------------------------------------------
    thanks in advanced for your answers

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: double header in a CListCtrl

    Have a look at Listcontrol grouping.
    http://www.codeproject.com/KB/list/C..._Grouping.aspx


    You can't have 2 different columnheaders if that's what you want, that'll need 2 listcontrols.

  3. #3
    Join Date
    Jan 2010
    Posts
    13

    Re: double header in a CListCtrl

    that's not exatly what i need, here the data are grouped on header, i only want to display data like this

    Code:
    |                       zone 1                      |
    |         zone 2         |       zone 3        |
    ----------------------------------------------
    |             123          |         456           |
    -----------------------------------------------

  4. #4
    Join Date
    Jan 2010
    Posts
    13

    Re: double header in a CListCtrl

    sorry for the up, but i really need an answer

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: double header in a CListCtrl

    Quote Originally Posted by mumuri View Post
    sorry for the up, but i really need an answer
    You already got an answer from OReubens (more than four months ago):
    Quote Originally Posted by OReubens View Post
    Have a look at Listcontrol grouping.
    http://www.codeproject.com/KB/list/C..._Grouping.aspx


    You can't have 2 different columnheaders if that's what you want, that'll need 2 listcontrols.
    If you however don't believe it is impossible - why didn't you try to search for it in http://www.codeproject.com/KB/list/#Header+Controls or/and http://www.codeguru.com/cpp/controls...headercontrol/
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: double header in a CListCtrl

    A CListCtrl is a "common control" it's a generic type control that's suitable for problems that fit into what it is designed to do. It can't solve all problems, and what you're asking is something it doesn't.
    So I stand by my answer that a CListctrl can't do what you're asking.

    What you ask will need a custom control (= you do all of the input and painting yourself). Depending on the details of what you need it may be possible to get it to work with just substituting (subclassing) the headercontrol in the listcontrol, although personal experience in that field would have me believe that this rarely works out. You'll probably will need to have a full custom list.

    You could search around if someone has already made the type of control you need. it could require purchasing a library though.

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: double header in a CListCtrl

    Quote Originally Posted by mumuri View Post
    sorry for the up, but i really need an answer
    I don't even understand how that would work. Looks like the columns wouldn't look like the header.

    You may be able to achieve something like that with a tab control, but I can't tell for sure what your objective is.

  8. #8
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: double header in a CListCtrl

    if I understand it right, he wants 'column groups'.
    so on the first row of the coolumns you would have something like

    Europe, America, Asia, Africa

    and on the 2nd row of the columns you would have a further subdivision of the 1st row.
    So the 'Europe' would be further divided into: Belgium, France, Germany, Italy, Portugal, Spain, ...
    America would be divided in: Canada, Mexico, United states, ...
    Asia: China, Japan, India, ...
    Africa: Kenia, Egypt, Morrocco, congo, ...

    While I have seen this approach before (on websites), I can't recall ever having seen this type of interface in a UI. where you can actually change the column widths etc.

    My gut feeling when I hear someone asking for these "awkward" / "unusual" types of controls is that you're probably much better off refactoring the problem so it fits into the usual type of controls, rather than confront your users with new types of controls they don't know how to use.
    Not that custom controls of any and all kind are bad, some are actually very necessary, particularly if it translates well to how users are used to working (when translating a phisical device into a UI) but the truth behind it is that they're often a LOT of work to write, and a lot of work to maintain having proper visual appearance as new versions of windows get released.
    Last edited by OReubens; October 27th, 2010 at 10:41 AM.

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