CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Please help!

  1. #1
    Join Date
    May 1999
    Posts
    76

    Please help!

    PLEASE HELP!

    I need to find out how to create something like this using a CListCtrl.

    Col 1|Col 2|Col 3
    ---------------------------------------------
    A.....B.....C

    I can get it set up with the columns, but I can't figure out how to insert items correctly into them.

    Dave2001,
    [email protected]

  2. #2
    Join Date
    May 1999
    Posts
    9

    Re: Please help!

    I expect you may have an answer by now, but if not...

    To insert an item into your CListCtrl use:

    int CListCtrl::InsertItem( int nItem, LPCTSTR lpszItem, int nImage )

    There are other overloads of this member function, see the MFC documentation.
    This will put the entry in the first column with text and an image (if you want one).

    You then need to insert the data for the other columns with successive calls to:

    BOOL CListCtrl::SetItem( int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
    int nImage, UINT nState, UINT nStateMask,
    LPARAM lParam );

    You pass the item number returned by InsertItem as nItem (this identifies the row). The parameter nSubItem identifies the column. For the second column (you already did the first one), use 1. For the third column, use 2 etc. For each column you obviously need a separate call to SetItem. Again, see MFC documentation for details of the other parameters (some of these have default values).

    Hope this helps.


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